Skip to content

Commit c4cff44

Browse files
committed
test/stack_traces.zig: add err union switch case
1 parent 7ef3d38 commit c4cff44

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

test/stack_traces.zig

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,4 +807,59 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
807807
,
808808
},
809809
});
810+
cases.addCase(.{
811+
.name = "error union switch with call operand",
812+
.source =
813+
\\pub fn main() !void {
814+
\\ try foo();
815+
\\ return error.TheSkyIsFalling;
816+
\\}
817+
\\
818+
\\noinline fn failure() error{ Fatal, NonFatal }!void {
819+
\\ return error.NonFatal;
820+
\\}
821+
\\
822+
\\fn foo() error{Fatal}!void {
823+
\\ return failure() catch |err| switch (err) {
824+
\\ error.Fatal => return error.Fatal,
825+
\\ error.NonFatal => return,
826+
\\ };
827+
\\}
828+
,
829+
.Debug = .{
830+
.expect =
831+
\\error: TheSkyIsFalling
832+
\\source.zig:3:5: [address] in main (test)
833+
\\ return error.TheSkyIsFalling;
834+
\\ ^
835+
\\
836+
,
837+
},
838+
.ReleaseSafe = .{
839+
.exclude_os = &.{
840+
.windows, // TODO
841+
.linux, // defeated by aggressive inlining
842+
},
843+
.expect =
844+
\\error: TheSkyIsFalling
845+
\\source.zig:3:5: [address] in [function]
846+
\\ return error.TheSkyIsFalling;
847+
\\ ^
848+
\\
849+
,
850+
.error_tracing = true,
851+
},
852+
.ReleaseFast = .{
853+
.expect =
854+
\\error: TheSkyIsFalling
855+
\\
856+
,
857+
},
858+
.ReleaseSmall = .{
859+
.expect =
860+
\\error: TheSkyIsFalling
861+
\\
862+
,
863+
},
864+
});
810865
}

0 commit comments

Comments
 (0)