diff options
author | LemonBoy <thatlemon@gmail.com> | 2018-06-23 13:37:35 +0200 |
---|---|---|
committer | LemonBoy <thatlemon@gmail.com> | 2018-06-23 13:40:11 +0200 |
commit | 7f0d7871eda6ec54a941b6a52f00ceb217bfe425 (patch) | |
tree | 698752c8521c8ea205fe01fda7c80e2c680fedb6 | |
parent | 3cbc07ac7877b03c605498760fe198e3200cc197 (diff) | |
download | Nim-7f0d7871eda6ec54a941b6a52f00ceb217bfe425.tar.gz |
Use the resolved typedesc in semVarOrLet
By leaving the unsemanticized node in the AST we'd trip some passes like the Transf one as seen in #7936.
-rw-r--r-- | compiler/semstmts.nim | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 3687e50e9..3528d0155 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -521,7 +521,9 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode = localError(c.config, a.info, errWrongNumberOfVariables) b = newNodeI(nkVarTuple, a.info) newSons(b, length) - b.sons[length-2] = a.sons[length-2] # keep type desc for doc generator + # keep type desc for doc generator + # NOTE: at the moment this is always ast.emptyNode, see parser.nim + b.sons[length-2] = a.sons[length-2] b.sons[length-1] = def addToVarSection(c, result, n, b) elif tup.kind == tyTuple and def.kind in {nkPar, nkTupleConstr} and @@ -560,7 +562,12 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode = # keep documentation information: b.comment = a.comment addSon(b, newSymNode(v)) - addSon(b, a.sons[length-2]) # keep type desc for doc generator + # keep type desc for doc generator, but only if the user explicitly + # added it + if a.sons[length-2].kind != nkEmpty: + addSon(b, newNodeIT(nkType, a.info, typ)) + else: + addSon(b, a.sons[length-2]) addSon(b, copyTree(def)) addToVarSection(c, result, n, b) else: |