diff options
author | Jake Leahy <jake@leahy.dev> | 2023-11-28 19:38:10 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-28 09:38:10 +0100 |
commit | 8cad6ac0487800f7d41e38303e52129777e6c22e (patch) | |
tree | f91a0a0164d2576a9859103cee32d321b205f075 /tests | |
parent | c31bbb07fb2d1ea8f69b47de50631442154bd3de (diff) | |
download | Nim-8cad6ac0487800f7d41e38303e52129777e6c22e.tar.gz |
Don't try and get enum value if its invalid (#22997)
Currently running `nimsuggest`/`check` on this code causes the compiler to raise an exception ```nim type Test = enum A = 9.0 ``` ``` assertions.nim(34) raiseAssert Error: unhandled exception: int128.nim(69, 11) `arg.sdata(3) == 0` out of range [AssertionDefect] ``` Issue was the compiler still trying to get the ordinal value even if it wasn't an ordinal
Diffstat (limited to 'tests')
-rw-r--r-- | tests/enum/tenum_invalid.nim | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/enum/tenum_invalid.nim b/tests/enum/tenum_invalid.nim new file mode 100644 index 000000000..8ae0a1057 --- /dev/null +++ b/tests/enum/tenum_invalid.nim @@ -0,0 +1,8 @@ +discard """ +cmd: "nim check $file" +""" + +type + Test = enum + A = 9.0 #[tt.Error + ^ ordinal type expected; given: float]# |