summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2019-08-12 14:06:48 +0200
committerAraq <rumpf_a@web.de>2019-08-12 14:06:48 +0200
commit322ce1872fd13e7b3029db800727ecdc886ad8a3 (patch)
treec5a88619eb47302b8e700a99144eca65c67a80cb /compiler
parent289b5e9ef93cd350e75f4d90d264e56df64c5a8d (diff)
downloadNim-322ce1872fd13e7b3029db800727ecdc886ad8a3.tar.gz
fixes #10689
Diffstat (limited to 'compiler')
-rw-r--r--compiler/injectdestructors.nim6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/injectdestructors.nim b/compiler/injectdestructors.nim
index 4f96d236f..87f09da59 100644
--- a/compiler/injectdestructors.nim
+++ b/compiler/injectdestructors.nim
@@ -796,7 +796,11 @@ proc p(n: PNode; c: var Con): PNode =
       result = n
   of nkAsgn, nkFastAsgn:
     if hasDestructor(n[0].typ) and n[1].kind notin {nkProcDef, nkDo, nkLambda}:
-      result = moveOrCopy(n[0], n[1], c)
+      # rule (self-assignment-removal):
+      if n[1].kind == nkSym and n[0].kind == nkSym and n[0].sym == n[1].sym:
+        result = newNodeI(nkEmpty, n.info)
+      else:
+        result = moveOrCopy(n[0], n[1], c)
     else:
       result = copyNode(n)
       recurse(n, result)