mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-20 16:01:29 +00:00
Float values are invalid in enum
This commit is contained in:
@@ -100,6 +100,8 @@ proc semEnum(c: PContext, n: PNode, prev: PType): PType =
|
||||
of tyString, tyCString:
|
||||
strVal = v
|
||||
x = counter
|
||||
of tyFloat..tyFloat128:
|
||||
localError(c.config, v.info, errOrdinalTypeExpected)
|
||||
else:
|
||||
x = getOrdValue(v)
|
||||
if i != 1:
|
||||
|
||||
@@ -6,5 +6,5 @@ line: 10
|
||||
# https://github.com/nim-lang/Nim/issues/9908
|
||||
|
||||
type
|
||||
X = enum
|
||||
a = ("a", "b")
|
||||
X = enum
|
||||
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
|
||||
Reference in New Issue
Block a user