mirror of
https://github.com/ziglang/zig.git
synced 2024-11-13 23:52:57 +00:00
test/stack_traces.zig: add err union switch case
This commit is contained in:
parent
7ef3d3876a
commit
c4cff443b8
@ -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
|
||||
\\
|
||||
,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user