From c70f67b0d679b1fe40e6cff9ec1d2fa517390971 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Fri, 24 Jan 2025 15:25:10 +0800 Subject: [PATCH] uses `topLevelScope` --- compiler/semexprs.nim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 75c914731f..d7ade66c36 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -2449,7 +2449,10 @@ proc semQuoteAst(c: PContext, n: PNode): PNode = 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 syms without backticks let oldScope = c.currentScope - c.currentScope = PScope(parent: nil, symbols: initStrTable(), depthLevel: 0) + # c.currentScope = PScope(parent: nil, symbols: initStrTable(), depthLevel: 0) + # TODO: allows toplevel syms to be captured for backwards compatibility + # perhaps `{.dirty.}` can be used for `dummyTemplate` + c.currentScope = c.topLevelScope var tmpl = semTemplateDef(c, dummyTemplate) c.currentScope = oldScope quotes[0] = tmpl[namePos]