summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2021-09-06 13:12:14 +0200
committerGitHub <noreply@github.com>2021-09-06 13:12:14 +0200
commit73841ae194c795674fc7b67460ada9c18a292b8e (patch)
tree7f191e12c1acadf493394aa78307b7285ce866ab /compiler
parent7ae52d779184cd8a16b760e384777a75ed54464b (diff)
downloadNim-73841ae194c795674fc7b67460ada9c18a292b8e.tar.gz
fixes #14165, fixes #18739, fix the second example of #6269 (#18812)
Diffstat (limited to 'compiler')
-rw-r--r--compiler/transf.nim11
1 files changed, 7 insertions, 4 deletions
diff --git a/compiler/transf.nim b/compiler/transf.nim
index 3250f2ec4..5846e6e3b 100644
--- a/compiler/transf.nim
+++ b/compiler/transf.nim
@@ -738,7 +738,7 @@ proc transformFor(c: PTransf, n: PNode): PNode =
   pushInfoContext(c.graph.config, n.info)
   inc(c.inlining)
   stmtList.add(transform(c, body))
-  #findWrongOwners(c, stmtList.pnode)
+  #findWrongOwners(c, stmtList.PNode)
   dec(c.inlining)
   popInfoContext(c.graph.config)
   popTransCon(c)
@@ -1019,10 +1019,11 @@ proc transform(c: PTransf, n: PNode): PNode =
   of nkAsgn:
     result = transformAsgn(c, n)
   of nkIdentDefs, nkConstDef:
-    result = n
+    result = newTransNode(n)
     result[0] = transform(c, n[0])
     # Skip the second son since it only contains an unsemanticized copy of the
     # variable type used by docgen
+    result[1] = n[1]
     result[2] = transform(c, n[2])
     # XXX comment handling really sucks:
     if importantComments(c.graph.config):
@@ -1033,8 +1034,10 @@ proc transform(c: PTransf, n: PNode): PNode =
     # (bug #2604). We need to patch this environment here too:
     let a = n[1]
     if a.kind == nkSym:
-      n[1] = transformSymAux(c, a)
-    return n
+      result = copyTree(n)
+      result[1] = transformSymAux(c, a)
+    else:
+      result = n
   of nkExceptBranch:
     result = transformExceptBranch(c, n)
   of nkCheckedFieldExpr: