From 8cad6ac0487800f7d41e38303e52129777e6c22e Mon Sep 17 00:00:00 2001 From: Jake Leahy Date: Tue, 28 Nov 2023 19:38:10 +1100 Subject: 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 --- tests/enum/tenum_invalid.nim | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 tests/enum/tenum_invalid.nim (limited to 'tests') 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]# -- cgit 1.4.1-2-gfad0