Better case coverage error message for alias and range enum (#12913)
This commit is contained in:
parent
148f6d9820
commit
3c38edf563
6 changed files with 100 additions and 70 deletions
14
tests/objvariant/tnon_zero_discrim_err.nim
Normal file
14
tests/objvariant/tnon_zero_discrim_err.nim
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
discard """
|
||||
errormsg: "low(kind) must be 0 for discriminant"
|
||||
line: 7
|
||||
"""
|
||||
type
|
||||
HoledObj = object
|
||||
case kind: int
|
||||
of 0: a: int
|
||||
else: discard
|
||||
|
||||
let someInt = low(int)
|
||||
case someInt
|
||||
of 938: echo HoledObj(kind: someInt, a: 1)
|
||||
else: discard
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
discard """
|
||||
errormsg: "low(kind) must be 0 for discriminant"
|
||||
line: 7
|
||||
errormsg: " branch initialization with a runtime discriminator only supports ordinal types with 2^16 elements or less."
|
||||
line: 13
|
||||
"""
|
||||
type
|
||||
HoledObj = object
|
||||
case kind: int
|
||||
case kind: range[0 .. 20000]
|
||||
of 0: a: int
|
||||
else: discard
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue