don't mark captured field sym in template as fully used (#24660)

fixes #24657

(cherry picked from commit 647c6687f1)
This commit is contained in:
metagn
2025-01-31 10:44:02 +03:00
committed by narimiran
parent 7cec03eb1b
commit a627c9ba9c
2 changed files with 15 additions and 1 deletions

View File

@@ -67,7 +67,12 @@ proc symChoice(c: PContext, n: PNode, s: PSym, r: TSymChoiceRule;
# for instance 'nextTry' is both in tables.nim and astalgo.nim ...
if not isField or sfGenSym notin s.flags:
result = newSymNode(s, info)
markUsed(c, info, s)
if isField:
# possibly not final field sym
incl(s.flags, sfUsed)
markOwnerModuleAsUsed(c, s)
else:
markUsed(c, info, s)
onUse(info, s)
else:
result = n

View File

@@ -0,0 +1,9 @@
# issue #24657
proc g() {.error.} = discard
type T = object
g: int
template B(): untyped = typeof(T.g)
type _ = B()