summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/destroyer.nim3
1 files changed, 2 insertions, 1 deletions
diff --git a/compiler/destroyer.nim b/compiler/destroyer.nim
index 59ee5dcb6..3811cccad 100644
--- a/compiler/destroyer.nim
+++ b/compiler/destroyer.nim
@@ -620,7 +620,8 @@ proc p(n: PNode; c: var Con): PNode =
   of nkAsgn, nkFastAsgn:
     if hasDestructor(n[0].typ):
       result = moveOrCopy(n[0], n[1], c)
-      c.enableDestructor(n[0].sym)
+      c.enableDestructor(n[0].sym) # last read to sink argument could have disabled the destructor
+                                   # but the variable is assigned again and new value should be destroyed
     else:
       result = copyNode(n)
       recurse(n, result)