retain forced open undeclared ident information (#22019)

(cherry picked from commit ce72b564bc)
This commit is contained in:
metagn
2023-06-07 12:36:51 +03:00
committed by narimiran
parent 876f6d69a8
commit 8f102f9e62
2 changed files with 20 additions and 4 deletions

View File

@@ -70,6 +70,9 @@ proc symChoice(c: PContext, n: PNode, s: PSym, r: TSymChoiceRule;
onUse(info, s)
else:
result = n
elif i == 0:
# forced open but symbol not in scope, retain information
result = n
else:
# semantic checking requires a type; ``fitNode`` deals with it
# appropriately
@@ -110,14 +113,10 @@ proc semBindStmt(c: PContext, n: PNode, toBind: var IntSet): PNode =
proc semMixinStmt(c: PContext, n: PNode, toMixin: var IntSet): PNode =
result = copyNode(n)
var count = 0
for i in 0..<n.len:
toMixin.incl(considerQuotedIdent(c, n[i]).id)
let x = symChoice(c, n[i], nil, scForceOpen)
inc count, x.len
result.add x
if count == 0:
result = newNodeI(nkEmpty, n.info)
proc replaceIdentBySym(c: PContext; n: var PNode, s: PNode) =
case n.kind

View File

@@ -0,0 +1,17 @@
discard """
nimout: '''
mixin nothing, add
'''
"""
# issue #22012
import macros
expandMacros:
proc foo[T](): int =
# `nothing` is undeclared, `add` is declared
mixin nothing, add
123
doAssert foo[int]() == 123