diff options
-rw-r--r-- | compiler/injectdestructors.nim | 8 | ||||
-rw-r--r-- | tests/destructor/twidgets.nim | 5 |
2 files changed, 7 insertions, 6 deletions
diff --git a/compiler/injectdestructors.nim b/compiler/injectdestructors.nim index 197d15490..3fbcf008b 100644 --- a/compiler/injectdestructors.nim +++ b/compiler/injectdestructors.nim @@ -732,11 +732,9 @@ proc p(n: PNode; c: var Con): PNode = # make sure it's destroyed at the end of the proc: if not isUnpackedTuple(it[0].sym): c.destroys.add genDestroy(c, v.typ, v) - if ri.kind != nkEmpty: - let r = moveOrCopy(v, ri, c) - result.add r - else: - result.add keepVar(n, it, c) + if ri.kind != nkEmpty: + let r = moveOrCopy(v, ri, c) + result.add r else: result.add keepVar(n, it, c) of nkCallKinds: diff --git a/tests/destructor/twidgets.nim b/tests/destructor/twidgets.nim index f7af1f75f..0495769bd 100644 --- a/tests/destructor/twidgets.nim +++ b/tests/destructor/twidgets.nim @@ -5,6 +5,9 @@ clicked!''' disabled: "true" """ +import core / allocators +import system / ansi_c + type Widget* = ref object of RootObj drawImpl: owned(proc (self: Widget)) @@ -71,4 +74,4 @@ proc main = main() let (a, d) = allocCounters() -discard cprintf("%ld %ld new: %ld\n", a, d, allocs) +discard cprintf("%ld %ld alloc/dealloc pairs: %ld\n", a, d, allocs) |