aboutsummaryrefslogtreecommitdiff
path: root/test/cases/compile_errors/zero_width_nonexhaustive_enum.zig
diff options
context:
space:
mode:
authorWill Lillis <will.lillis24@gmail.com>2025-02-01 22:36:16 -0500
committerGitHub <noreply@github.com>2025-02-02 03:36:16 +0000
commit953355ebeab881abff4a2c9315daa4fbb290d733 (patch)
tree28e266010b69995fab79197a43a583bb5e511945 /test/cases/compile_errors/zero_width_nonexhaustive_enum.zig
parent963651bbf292b21017cac9e977a933b5e2a8c671 (diff)
downloadzig-953355ebeab881abff4a2c9315daa4fbb290d733.tar.gz
zig-953355ebeab881abff4a2c9315daa4fbb290d733.zip
fix: error on non-exhaustive enums with zero width backing type (#21374)
Co-authored-by: WillLillis <wlillis@umass.edu>
Diffstat (limited to 'test/cases/compile_errors/zero_width_nonexhaustive_enum.zig')
-rw-r--r--test/cases/compile_errors/zero_width_nonexhaustive_enum.zig17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/cases/compile_errors/zero_width_nonexhaustive_enum.zig b/test/cases/compile_errors/zero_width_nonexhaustive_enum.zig
new file mode 100644
index 0000000000..a38c5f357a
--- /dev/null
+++ b/test/cases/compile_errors/zero_width_nonexhaustive_enum.zig
@@ -0,0 +1,17 @@
+comptime {
+ _ = enum(i0) { a, _ };
+}
+
+comptime {
+ _ = enum(u0) { a, _ };
+}
+
+comptime {
+ _ = enum(u0) { a, b, _ };
+}
+
+// error
+//
+// :2:9: error: non-exhaustive enum specifies every value
+// :6:9: error: non-exhaustive enum specifies every value
+// :10:23: error: enumeration value '1' too large for type 'u0'