Float values are invalid in enum

This commit is contained in:
Neelesh Chandola
2018-12-09 14:20:01 +05:30
parent d977fc6f32
commit e44641b6cb
3 changed files with 14 additions and 2 deletions

View File

@@ -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:

View File

@@ -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")

View 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