mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-03 11:42:33 +00:00
[backport] Handle nkOpenSymChoice for nkAccQuoted in considerQuotedIdent (#20578)
* Handle nkOpenSymChoice for nkAccQuoted in considerQuotedIdent
* Add test
* Update compiler/lookups.nim
Co-authored-by: SirOlaf <a>
Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
(cherry picked from commit 2f441ac675)
This commit is contained in:
@@ -44,6 +44,11 @@ proc considerQuotedIdent*(c: PContext; n: PNode, origin: PNode = nil): PIdent =
|
||||
case x.kind
|
||||
of nkIdent: id.add(x.ident.s)
|
||||
of nkSym: id.add(x.sym.name.s)
|
||||
of nkSymChoices:
|
||||
if x[0].kind == nkSym:
|
||||
id.add(x[0].sym.name.s)
|
||||
else:
|
||||
handleError(n, origin)
|
||||
of nkLiterals - nkFloatLiterals: id.add(x.renderTree)
|
||||
else: handleError(n, origin)
|
||||
result = getIdent(c.cache, id)
|
||||
|
||||
@@ -353,3 +353,18 @@ block gensym3:
|
||||
echo a ! b ! c ! d
|
||||
echo a ! b ! c ! d ! e
|
||||
echo x,y,z
|
||||
|
||||
|
||||
block identifier_construction_with_overridden_symbol:
|
||||
# could use add, but wanna make sure it's an override no matter what
|
||||
func examplefn = discard
|
||||
func examplefn(x: int) = discard
|
||||
|
||||
# the function our template wants to use
|
||||
func examplefn1 = discard
|
||||
|
||||
template exampletempl(n) =
|
||||
# attempt to build a name using the overridden symbol "examplefn"
|
||||
`examplefn n`()
|
||||
|
||||
exampletempl(1)
|
||||
|
||||
Reference in New Issue
Block a user