diff options
-rw-r--r-- | compiler/semtypes.nim | 2 | ||||
-rw-r--r-- | tests/errmsgs/t9908_01.nim (renamed from tests/errmsgs/t9908.nim) | 4 | ||||
-rw-r--r-- | tests/errmsgs/t9908_02.nim | 10 |
3 files changed, 14 insertions, 2 deletions
diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index 294cabe47..4cc759e52 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -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: diff --git a/tests/errmsgs/t9908.nim b/tests/errmsgs/t9908_01.nim index fa086517f..b9d37b67b 100644 --- a/tests/errmsgs/t9908.nim +++ b/tests/errmsgs/t9908_01.nim @@ -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") diff --git a/tests/errmsgs/t9908_02.nim b/tests/errmsgs/t9908_02.nim new file mode 100644 index 000000000..7ff3d1ff7 --- /dev/null +++ b/tests/errmsgs/t9908_02.nim @@ -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 |