fixes #25908; resolves lent enum disambiguation (#25929)

fixes #25908

When an enum identifier is resolved as an `nkSymChoice`, one of the
candidates may come from a loop-local view and carry `tyVar` or
`tyLent`.

Enum disambiguation should compare the underlying enum type only.
Otherwise a pure-enum field can win incorrectly even though the intended
symbol is already present in the choice set.

Keep the `includePureEnum` lookup path for enum-typed expectations so
#23976 still works, but normalize `var`/`lent` only at the symchoice
selection point.
This commit is contained in:
ringabout
2026-06-23 18:22:29 +08:00
committed by GitHub
parent f8e470eb57
commit 6eef0cc2d5
3 changed files with 15 additions and 1 deletions

View File

@@ -283,3 +283,13 @@ block: # bug #23952
doAssert s1 != s2
static: foo()
foo()
# bug #25908
type S {.pure.} = enum a, b
iterator foo(x: array[1, S]): lent S =
yield x[0]
iterator f(_: int | int): S =
for a in foo([S.b]): yield a
for v in f(0): doAssert v == S.b