aboutsummaryrefslogtreecommitdiff
path: root/test/cases/compile_errors/destructure_error_union.zig
diff options
context:
space:
mode:
authorWill Lillis <wlillis@umass.edu>2024-09-23 16:04:24 -0400
committerGitHub <noreply@github.com>2024-09-23 13:04:24 -0700
commit943176bbfcf3125451fa64e082ee357c28e70413 (patch)
tree7b72a227aadaaf5d96d59240ea6c97c12cbf1753 /test/cases/compile_errors/destructure_error_union.zig
parent509639717ac8903fe340a02cef844383183bf716 (diff)
downloadzig-943176bbfcf3125451fa64e082ee357c28e70413.tar.gz
zig-943176bbfcf3125451fa64e082ee357c28e70413.zip
fix: Add error note when attempt is made to destructure error union (#21491)
closes #21417
Diffstat (limited to 'test/cases/compile_errors/destructure_error_union.zig')
-rw-r--r--test/cases/compile_errors/destructure_error_union.zig15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/cases/compile_errors/destructure_error_union.zig b/test/cases/compile_errors/destructure_error_union.zig
new file mode 100644
index 0000000000..fb5872707d
--- /dev/null
+++ b/test/cases/compile_errors/destructure_error_union.zig
@@ -0,0 +1,15 @@
+pub export fn entry() void {
+ const Foo = struct { u8, u8 };
+ const foo: anyerror!Foo = error.Failure;
+ const bar, const baz = foo;
+ _ = bar;
+ _ = baz;
+}
+
+// error
+// backend=stage2
+// target=native
+//
+// :4:28: error: type 'anyerror!tmp.entry.Foo' cannot be destructured
+// :4:26: note: result destructured here
+// :4:28: note: consider using 'try', 'catch', or 'if'