Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion compiler/sem.nim
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,12 @@ proc fitNode(c: PContext, formal: PType, arg: PNode; info: TLineInfo): PNode =
result.typ = formal
elif arg.kind in nkSymChoices and formal.skipTypes(abstractInst).kind == tyEnum:
# Pick the right 'sym' from the sym choice by looking at 'formal' type:
# The choice candidates may be wrapped in `var`/`lent` when they come from
# a loop-local view, but for enum disambiguation only the underlying enum
# type matters.
result = nil
for ch in arg:
if sameType(ch.typ, formal):
if sameType(ch.typ.skipTypes({tyVar, tyLent}), formal):
return ch
typeMismatch(c.config, info, formal, arg.typ, arg)
else:
Expand Down
1 change: 1 addition & 0 deletions testament/important_packages.nim
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ pkg "sim"
pkg "smtp", "nimble compileExample"
pkg "snip", "nimble test", "https://github.com/genotrance/snip"
pkg "ssostrings", "nim c -r tests/tssostrings.nim"
pkg "ssz_serialization", "nim c -r tests/test_all.nim"
pkg "stew"
pkg "stint", "nimble test_internal"
pkg "strslice"
Expand Down
10 changes: 10 additions & 0 deletions tests/enum/tenum.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading