fixes #24641; quote do captures no variables under current macros

This commit is contained in:
ringabout
2025-01-23 21:45:31 +08:00
parent 6d59680217
commit b550fb54d9

View File

@@ -2447,7 +2447,11 @@ proc semQuoteAst(c: PContext, n: PNode): PNode =
dummyTemplate[paramsPos].add newTreeI(nkIdentDefs, n.info, ids[i], newNodeIT(nkType, n.info, typ), c.graph.emptyNode)
else:
dummyTemplate[paramsPos].add newTreeI(nkIdentDefs, n.info, ids[i], getSysSym(c.graph, n.info, "typed").newSymNode, c.graph.emptyNode)
# don't allow templates to capture variables in macors without backticks
let oldScope = c.currentScope
c.currentScope = c.topLevelScope
var tmpl = semTemplateDef(c, dummyTemplate)
c.currentScope = oldScope
quotes[0] = tmpl[namePos]
# This adds a call to newIdentNode("result") as the first argument to the template call
let identNodeSym = getCompilerProc(c.graph, "newIdentNode")