Skip to content

Commit

Permalink
don't mark captured field sym in template as fully used
Browse files Browse the repository at this point in the history
fixes #24657
  • Loading branch information
metagn committed Jan 30, 2025
1 parent cab3342 commit 3d9744b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 6 additions & 1 deletion compiler/semtempl.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions tests/template/tfielduse.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# issue #24657

proc g() {.error.} = discard

type T = object
g: int

template B(): untyped = typeof(T.g)
type _ = B()

0 comments on commit 3d9744b

Please sign in to comment.