Skip to content

Commit

Permalink
test/stack_traces.zig: add err union switch case
Browse files Browse the repository at this point in the history
  • Loading branch information
dweiller committed Jan 18, 2024
1 parent 7ef3d38 commit c4cff44
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions test/stack_traces.zig
Original file line number Diff line number Diff line change
Expand Up @@ -807,4 +807,59 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
,
},
});
cases.addCase(.{
.name = "error union switch with call operand",
.source =
\\pub fn main() !void {
\\ try foo();
\\ return error.TheSkyIsFalling;
\\}
\\
\\noinline fn failure() error{ Fatal, NonFatal }!void {
\\ return error.NonFatal;
\\}
\\
\\fn foo() error{Fatal}!void {
\\ return failure() catch |err| switch (err) {
\\ error.Fatal => return error.Fatal,
\\ error.NonFatal => return,
\\ };
\\}
,
.Debug = .{
.expect =
\\error: TheSkyIsFalling
\\source.zig:3:5: [address] in main (test)
\\ return error.TheSkyIsFalling;
\\ ^
\\
,
},
.ReleaseSafe = .{
.exclude_os = &.{
.windows, // TODO
.linux, // defeated by aggressive inlining
},
.expect =
\\error: TheSkyIsFalling
\\source.zig:3:5: [address] in [function]
\\ return error.TheSkyIsFalling;
\\ ^
\\
,
.error_tracing = true,
},
.ReleaseFast = .{
.expect =
\\error: TheSkyIsFalling
\\
,
},
.ReleaseSmall = .{
.expect =
\\error: TheSkyIsFalling
\\
,
},
});
}

0 comments on commit c4cff44

Please sign in to comment.