fix #12094 Use of _ (as var placeholder) inside a template causes XDe… (#20635)

fix #12094 Use of _ (as var placeholder) inside a template causes XDeclaredButNotUsed

(cherry picked from commit 4728c52c78)
This commit is contained in:
Bung
2022-10-25 14:43:14 +08:00
committed by narimiran
parent 5c4044cd80
commit 628c9c3c7f

View File

@@ -360,7 +360,8 @@ proc addToVarSection(c: PContext; result: PNode; orig, identDefs: PNode) =
result.add identDefs
proc isDiscardUnderscore(v: PSym): bool =
if v.name.s == "_":
# template generated underscore symbol name starts with _`gensym
if v.name.s == "_" or v.name.s.startsWith("_`"):
v.flags.incl(sfGenSym)
result = true