Float values are invalid in enum
This commit is contained in:
parent
d977fc6f32
commit
e44641b6cb
3 changed files with 14 additions and 2 deletions
|
|
@ -100,6 +100,8 @@ proc semEnum(c: PContext, n: PNode, prev: PType): PType =
|
||||||
of tyString, tyCString:
|
of tyString, tyCString:
|
||||||
strVal = v
|
strVal = v
|
||||||
x = counter
|
x = counter
|
||||||
|
of tyFloat..tyFloat128:
|
||||||
|
localError(c.config, v.info, errOrdinalTypeExpected)
|
||||||
else:
|
else:
|
||||||
x = getOrdValue(v)
|
x = getOrdValue(v)
|
||||||
if i != 1:
|
if i != 1:
|
||||||
|
|
|
||||||
|
|
@ -6,5 +6,5 @@ line: 10
|
||||||
# https://github.com/nim-lang/Nim/issues/9908
|
# https://github.com/nim-lang/Nim/issues/9908
|
||||||
|
|
||||||
type
|
type
|
||||||
X = enum
|
X = enum
|
||||||
a = ("a", "b")
|
a = ("a", "b")
|
||||||
10
tests/errmsgs/t9908_02.nim
Normal file
10
tests/errmsgs/t9908_02.nim
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
discard """
|
||||||
|
errormsg: "ordinal type expected"
|
||||||
|
line: 10
|
||||||
|
"""
|
||||||
|
|
||||||
|
# https://github.com/nim-lang/Nim/pull/9909#issuecomment-445519287
|
||||||
|
|
||||||
|
type
|
||||||
|
E = enum
|
||||||
|
myVal = 80.9
|
||||||
Loading…
Add table
Add a link
Reference in a new issue