summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBung <crc32@qq.com>2022-10-25 14:43:14 +0800
committerGitHub <noreply@github.com>2022-10-25 08:43:14 +0200
commit4728c52c787b19c60a5533e20b7d71ee9ca137a3 (patch)
treef21f34401e9179dcbfe49feb288651bc3112be15
parent8ed2431db0d95bb30d69c563a137e348cd299621 (diff)
downloadNim-4728c52c787b19c60a5533e20b7d71ee9ca137a3.tar.gz
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
-rw-r--r--compiler/semstmts.nim3
1 files changed, 2 insertions, 1 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index 596995adb..81be67725 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -370,7 +370,8 @@ proc addToVarSection(c: PContext; result: var 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