diff options
| author | Veikka Tuominen <git@vexu.eu> | 2023-01-02 17:06:06 +0200 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2023-01-02 17:06:06 +0200 |
| commit | 332a43858a6ba2128d3df9e6bca45a10547ed383 (patch) | |
| tree | 31d0a0eb6fe120e0d375d58655cef8fe555b05b8 /test/cases/compile_errors | |
| parent | aadd1b252e1d912e45cc924a15872d7c3d1f9080 (diff) | |
| download | zig-332a43858a6ba2128d3df9e6bca45a10547ed383.tar.gz zig-332a43858a6ba2128d3df9e6bca45a10547ed383.zip | |
Sema: `@intToEnum` on non-exhaustive enum at comptime should check int is in range
Closes #14155
Diffstat (limited to 'test/cases/compile_errors')
| -rw-r--r-- | test/cases/compile_errors/intToEnum_on_non-exhaustive_enums_checks_int_in_range.zig | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/cases/compile_errors/intToEnum_on_non-exhaustive_enums_checks_int_in_range.zig b/test/cases/compile_errors/intToEnum_on_non-exhaustive_enums_checks_int_in_range.zig new file mode 100644 index 0000000000..b05c9f35d9 --- /dev/null +++ b/test/cases/compile_errors/intToEnum_on_non-exhaustive_enums_checks_int_in_range.zig @@ -0,0 +1,11 @@ +pub export fn entry() void { + const E = enum(u3) { a, b, c, _ }; + @compileLog(@intToEnum(E, 100)); +} + +// error +// target=native +// backend=stage2 +// +// :3:17: error: int value '100' out of range of non-exhaustive enum 'tmp.entry.E' +// :2:15: note: enum declared here |
