fix codegen bug due to changing existing symbol declaration in template (#14666)

This commit is contained in:
jcosborn 2020-06-15 01:40:12 -05:00 • committed by GitHub
commit 5a22d6b57b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 107 additions and 1 deletions

View file

@ -229,7 +229,7 @@ proc addLocalDecl(c: var TemplCtx, n: var PNode, k: TSymKind) =
if s != nil and s.owner == c.owner and sfGenSym in s.flags:
onUse(n.info, s)
replaceIdentBySym(c.c, n, newSymNode(s, n.info))
elif not (n.kind == nkSym and sfGenSym in n.sym.flags):
elif n.kind != nkSym:
let local = newGenSym(k, ident, c)
addPrelimDecl(c.c, local)
styleCheckDef(c.c.config, n.info, local)