Skip to content

Commit b550fb5

Browse files
committed
fixes #24641; quote do captures no variables under current macros
1 parent 6d59680 commit b550fb5

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

compiler/semexprs.nim

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

0 commit comments

Comments
 (0)