summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2020-03-09 15:32:38 +0100
committerGitHub <noreply@github.com>2020-03-09 15:32:38 +0100
commit63af8ae53ca8e1ffd61a2c2d55d09c5fe30310e1 (patch)
tree64f73cf00505159f9720aa6113e07ad1dcdf6857 /compiler
parent4aecc6b3465411d99dbd94e89c1bb3eb371d6fa6 (diff)
downloadNim-63af8ae53ca8e1ffd61a2c2d55d09c5fe30310e1.tar.gz
fixes #13596 (#13612)
Diffstat (limited to 'compiler')
-rw-r--r--compiler/transf.nim13
1 files changed, 13 insertions, 0 deletions
diff --git a/compiler/transf.nim b/compiler/transf.nim
index 68ef464c4..cd5eaa100 100644
--- a/compiler/transf.nim
+++ b/compiler/transf.nim
@@ -128,6 +128,19 @@ proc transformSymAux(c: PTransf, n: PNode): PNode =
     b = s.getBody
     if b.kind != nkSym: internalError(c.graph.config, n.info, "wrong AST for borrowed symbol")
     b = newSymNode(b.sym, n.info)
+  elif c.inlining > 0:
+    # see bug #13596: we use ref-based equality in the DFA for destruction
+    # injections so we need to ensure unique nodes after iterator inlining
+    # which can lead to duplicated for loop bodies! Consider:
+    #[
+      while remaining > 0:
+        if ending == nil:
+          yield ms
+          break
+        ...
+        yield ms
+    ]#
+    b = newSymNode(n.sym, n.info)
   else:
     b = n
   while tc != nil: