mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-18 17:08:32 +00:00
@@ -370,8 +370,7 @@ proc addToVarSection(c: PContext; result: var PNode; orig, identDefs: PNode) =
|
||||
result.add identDefs
|
||||
|
||||
proc isDiscardUnderscore(v: PSym): bool =
|
||||
# template generated underscore symbol name starts with _`gensym
|
||||
if v.name.s == "_" or v.name.s.startsWith("_`"):
|
||||
if v.name.s == "_":
|
||||
v.flags.incl(sfGenSym)
|
||||
result = true
|
||||
|
||||
|
||||
@@ -227,7 +227,7 @@ proc addLocalDecl(c: var TemplCtx, n: var PNode, k: TSymKind) =
|
||||
closeScope(c)
|
||||
let ident = getIdentNode(c, n)
|
||||
if not isTemplParam(c, ident):
|
||||
if n.kind != nkSym:
|
||||
if n.kind != nkSym and not (n.kind == nkIdent and n.ident.s == "_"):
|
||||
let local = newGenSym(k, ident, c)
|
||||
addPrelimDecl(c.c, local)
|
||||
styleCheckDef(c.c, n.info, local)
|
||||
|
||||
11
tests/template/tunderscore1.nim
Normal file
11
tests/template/tunderscore1.nim
Normal file
@@ -0,0 +1,11 @@
|
||||
discard """
|
||||
errormsg: "undeclared identifier: '_'"
|
||||
"""
|
||||
|
||||
# issue #12094, #13804
|
||||
|
||||
template foo =
|
||||
let _ = 1
|
||||
echo _
|
||||
|
||||
foo()
|
||||
Reference in New Issue
Block a user