aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/cases/switch_prong_err_enum.zig29
-rw-r--r--test/self_hosted.zig1
2 files changed, 30 insertions, 0 deletions
diff --git a/test/cases/switch_prong_err_enum.zig b/test/cases/switch_prong_err_enum.zig
new file mode 100644
index 0000000000..cb8c864357
--- /dev/null
+++ b/test/cases/switch_prong_err_enum.zig
@@ -0,0 +1,29 @@
+const assert = @import("std").debug.assert;
+
+var read_count: u64 = 0;
+
+fn readOnce() -> %u64 {
+ read_count += 1;
+ return read_count;
+}
+
+error InvalidDebugInfo;
+
+enum FormValue {
+ Address: u64,
+ Other: bool,
+}
+
+#static_eval_enable(false)
+fn doThing(form_id: u64) -> %FormValue {
+ return switch (form_id) {
+ 17 => FormValue.Address { %return readOnce() },
+ else => error.InvalidDebugInfo,
+ }
+}
+
+#attribute("test")
+fn switchProngReturnsErrorEnum() {
+ %%doThing(17);
+ assert(read_count == 1);
+}
diff --git a/test/self_hosted.zig b/test/self_hosted.zig
index 2a8814b17a..7b58684b05 100644
--- a/test/self_hosted.zig
+++ b/test/self_hosted.zig
@@ -12,6 +12,7 @@ const test_max_value_type = @import("cases/max_value_type.zig");
const test_var_params = @import("cases/var_params.zig");
const test_const_slice_child = @import("cases/const_slice_child.zig");
const test_switch_prong_implicit_cast = @import("cases/switch_prong_implicit_cast.zig");
+const test_switch_prong_err_enum = @import("cases/switch_prong_err_enum.zig");
// normal comment
/// this is a documentation comment