Float values are invalid in enum

This commit is contained in:
Neelesh Chandola 2018-12-09 14:20:01 +05:30
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: 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:

View file

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

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