2019-05-27 17:07:05 -07:00
|
|
|
const builtin = @import("builtin");
|
|
|
|
const std = @import("std");
|
|
|
|
const os = std.os;
|
|
|
|
const tests = @import("tests.zig");
|
|
|
|
|
2019-09-03 07:08:39 -07:00
|
|
|
pub fn addCases(cases: *tests.StackTracesContext) void {
|
2019-05-27 17:07:05 -07:00
|
|
|
const source_return =
|
|
|
|
\\const std = @import("std");
|
|
|
|
\\
|
|
|
|
\\pub fn main() !void {
|
|
|
|
\\ return error.TheSkyIsFalling;
|
|
|
|
\\}
|
|
|
|
;
|
|
|
|
const source_try_return =
|
|
|
|
\\const std = @import("std");
|
|
|
|
\\
|
|
|
|
\\fn foo() !void {
|
|
|
|
\\ return error.TheSkyIsFalling;
|
|
|
|
\\}
|
|
|
|
\\
|
|
|
|
\\pub fn main() !void {
|
|
|
|
\\ try foo();
|
|
|
|
\\}
|
|
|
|
;
|
|
|
|
const source_try_try_return_return =
|
|
|
|
\\const std = @import("std");
|
|
|
|
\\
|
|
|
|
\\fn foo() !void {
|
|
|
|
\\ try bar();
|
|
|
|
\\}
|
|
|
|
\\
|
|
|
|
\\fn bar() !void {
|
|
|
|
\\ return make_error();
|
|
|
|
\\}
|
|
|
|
\\
|
|
|
|
\\fn make_error() !void {
|
|
|
|
\\ return error.TheSkyIsFalling;
|
|
|
|
\\}
|
|
|
|
\\
|
|
|
|
\\pub fn main() !void {
|
|
|
|
\\ try foo();
|
|
|
|
\\}
|
|
|
|
;
|
2019-09-07 20:04:01 -07:00
|
|
|
// zig fmt: off
|
2019-05-27 17:07:05 -07:00
|
|
|
switch (builtin.os) {
|
2019-09-07 20:04:01 -07:00
|
|
|
.freebsd => {
|
|
|
|
cases.addCase(
|
|
|
|
"return",
|
|
|
|
source_return,
|
|
|
|
[_][]const u8{
|
|
|
|
// debug
|
|
|
|
\\error: TheSkyIsFalling
|
|
|
|
\\source.zig:4:5: [address] in main (test)
|
|
|
|
\\
|
|
|
|
,
|
|
|
|
// release-safe
|
|
|
|
\\error: TheSkyIsFalling
|
2019-12-12 16:43:04 -08:00
|
|
|
\\source.zig:4:5: [address] in std.start.main (test)
|
2019-09-07 20:04:01 -07:00
|
|
|
\\
|
|
|
|
,
|
|
|
|
// release-fast
|
|
|
|
\\error: TheSkyIsFalling
|
|
|
|
\\
|
|
|
|
,
|
|
|
|
// release-small
|
|
|
|
\\error: TheSkyIsFalling
|
|
|
|
\\
|
|
|
|
},
|
|
|
|
);
|
|
|
|
cases.addCase(
|
|
|
|
"try return",
|
|
|
|
source_try_return,
|
|
|
|
[_][]const u8{
|
|
|
|
// debug
|
|
|
|
\\error: TheSkyIsFalling
|
|
|
|
\\source.zig:4:5: [address] in foo (test)
|
|
|
|
\\source.zig:8:5: [address] in main (test)
|
|
|
|
\\
|
|
|
|
,
|
|
|
|
// release-safe
|
|
|
|
\\error: TheSkyIsFalling
|
2019-12-12 16:43:04 -08:00
|
|
|
\\source.zig:4:5: [address] in std.start.main (test)
|
|
|
|
\\source.zig:8:5: [address] in std.start.main (test)
|
2019-09-07 20:04:01 -07:00
|
|
|
\\
|
|
|
|
,
|
|
|
|
// release-fast
|
|
|
|
\\error: TheSkyIsFalling
|
|
|
|
\\
|
|
|
|
,
|
|
|
|
// release-small
|
|
|
|
\\error: TheSkyIsFalling
|
|
|
|
\\
|
|
|
|
},
|
|
|
|
);
|
|
|
|
cases.addCase(
|
|
|
|
"try try return return",
|
|
|
|
source_try_try_return_return,
|
|
|
|
[_][]const u8{
|
|
|
|
// debug
|
|
|
|
\\error: TheSkyIsFalling
|
|
|
|
\\source.zig:12:5: [address] in make_error (test)
|
|
|
|
\\source.zig:8:5: [address] in bar (test)
|
|
|
|
\\source.zig:4:5: [address] in foo (test)
|
|
|
|
\\source.zig:16:5: [address] in main (test)
|
|
|
|
\\
|
|
|
|
,
|
|
|
|
// release-safe
|
|
|
|
\\error: TheSkyIsFalling
|
2019-12-12 16:43:04 -08:00
|
|
|
\\source.zig:12:5: [address] in std.start.main (test)
|
|
|
|
\\source.zig:8:5: [address] in std.start.main (test)
|
|
|
|
\\source.zig:4:5: [address] in std.start.main (test)
|
|
|
|
\\source.zig:16:5: [address] in std.start.main (test)
|
2019-09-07 20:04:01 -07:00
|
|
|
\\
|
|
|
|
,
|
|
|
|
// release-fast
|
|
|
|
\\error: TheSkyIsFalling
|
|
|
|
\\
|
|
|
|
,
|
|
|
|
// release-small
|
|
|
|
\\error: TheSkyIsFalling
|
|
|
|
\\
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
2019-05-27 17:07:05 -07:00
|
|
|
.linux => {
|
|
|
|
cases.addCase(
|
|
|
|
"return",
|
|
|
|
source_return,
|
2019-09-03 07:05:19 -07:00
|
|
|
[_][]const u8{
|
|
|
|
// debug
|
2019-09-07 20:04:01 -07:00
|
|
|
\\error: TheSkyIsFalling
|
2019-05-27 17:07:05 -07:00
|
|
|
\\source.zig:4:5: [address] in main (test)
|
|
|
|
\\
|
|
|
|
,
|
2019-09-03 07:05:19 -07:00
|
|
|
// release-safe
|
2019-09-07 20:04:01 -07:00
|
|
|
\\error: TheSkyIsFalling
|
2019-12-12 16:43:04 -08:00
|
|
|
\\source.zig:4:5: [address] in std.start.posixCallMainAndExit (test)
|
2019-05-27 17:07:05 -07:00
|
|
|
\\
|
|
|
|
,
|
2019-09-03 07:05:19 -07:00
|
|
|
// release-fast
|
2019-09-07 20:04:01 -07:00
|
|
|
\\error: TheSkyIsFalling
|
2019-05-27 17:07:05 -07:00
|
|
|
\\
|
|
|
|
,
|
2019-09-03 07:05:19 -07:00
|
|
|
// release-small
|
2019-09-07 20:04:01 -07:00
|
|
|
\\error: TheSkyIsFalling
|
2019-05-27 17:07:05 -07:00
|
|
|
\\
|
|
|
|
},
|
|
|
|
);
|
|
|
|
cases.addCase(
|
|
|
|
"try return",
|
|
|
|
source_try_return,
|
2019-09-03 07:05:19 -07:00
|
|
|
[_][]const u8{
|
|
|
|
// debug
|
2019-09-07 20:04:01 -07:00
|
|
|
\\error: TheSkyIsFalling
|
2019-05-27 17:07:05 -07:00
|
|
|
\\source.zig:4:5: [address] in foo (test)
|
|
|
|
\\source.zig:8:5: [address] in main (test)
|
|
|
|
\\
|
|
|
|
,
|
2019-09-03 07:05:19 -07:00
|
|
|
// release-safe
|
2019-09-07 20:04:01 -07:00
|
|
|
\\error: TheSkyIsFalling
|
2019-12-12 16:43:04 -08:00
|
|
|
\\source.zig:4:5: [address] in std.start.posixCallMainAndExit (test)
|
|
|
|
\\source.zig:8:5: [address] in std.start.posixCallMainAndExit (test)
|
2019-05-27 17:07:05 -07:00
|
|
|
\\
|
|
|
|
,
|
2019-09-03 07:05:19 -07:00
|
|
|
// release-fast
|
2019-09-07 20:04:01 -07:00
|
|
|
\\error: TheSkyIsFalling
|
2019-05-27 17:07:05 -07:00
|
|
|
\\
|
|
|
|
,
|
2019-09-03 07:05:19 -07:00
|
|
|
// release-small
|
2019-09-07 20:04:01 -07:00
|
|
|
\\error: TheSkyIsFalling
|
2019-05-27 17:07:05 -07:00
|
|
|
\\
|
|
|
|
},
|
|
|
|
);
|
|
|
|
cases.addCase(
|
|
|
|
"try try return return",
|
|
|
|
source_try_try_return_return,
|
2019-09-03 07:05:19 -07:00
|
|
|
[_][]const u8{
|
|
|
|
// debug
|
2019-09-07 20:04:01 -07:00
|
|
|
\\error: TheSkyIsFalling
|
2019-05-27 17:07:05 -07:00
|
|
|
\\source.zig:12:5: [address] in make_error (test)
|
|
|
|
\\source.zig:8:5: [address] in bar (test)
|
|
|
|
\\source.zig:4:5: [address] in foo (test)
|
|
|
|
\\source.zig:16:5: [address] in main (test)
|
|
|
|
\\
|
|
|
|
,
|
2019-09-03 07:05:19 -07:00
|
|
|
// release-safe
|
2019-09-07 20:04:01 -07:00
|
|
|
\\error: TheSkyIsFalling
|
2019-12-12 16:43:04 -08:00
|
|
|
\\source.zig:12:5: [address] in std.start.posixCallMainAndExit (test)
|
|
|
|
\\source.zig:8:5: [address] in std.start.posixCallMainAndExit (test)
|
|
|
|
\\source.zig:4:5: [address] in std.start.posixCallMainAndExit (test)
|
|
|
|
\\source.zig:16:5: [address] in std.start.posixCallMainAndExit (test)
|
2019-05-27 17:07:05 -07:00
|
|
|
\\
|
|
|
|
,
|
2019-09-03 07:05:19 -07:00
|
|
|
// release-fast
|
2019-09-07 20:04:01 -07:00
|
|
|
\\error: TheSkyIsFalling
|
2019-05-27 17:07:05 -07:00
|
|
|
\\
|
|
|
|
,
|
2019-09-03 07:05:19 -07:00
|
|
|
// release-small
|
2019-09-07 20:04:01 -07:00
|
|
|
\\error: TheSkyIsFalling
|
2019-05-27 17:07:05 -07:00
|
|
|
\\
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
.macosx => {
|
|
|
|
cases.addCase(
|
|
|
|
"return",
|
|
|
|
source_return,
|
2019-09-03 07:05:19 -07:00
|
|
|
[_][]const u8{
|
|
|
|
// debug
|
2019-09-07 20:04:01 -07:00
|
|
|
\\error: TheSkyIsFalling
|
2019-05-27 17:07:05 -07:00
|
|
|
\\source.zig:4:5: [address] in _main.0 (test.o)
|
|
|
|
\\
|
|
|
|
,
|
2019-09-03 07:05:19 -07:00
|
|
|
// release-safe
|
2019-09-07 20:04:01 -07:00
|
|
|
\\error: TheSkyIsFalling
|
2019-05-27 17:07:05 -07:00
|
|
|
\\source.zig:4:5: [address] in _main (test.o)
|
|
|
|
\\
|
|
|
|
,
|
2019-09-03 07:05:19 -07:00
|
|
|
// release-fast
|
2019-09-07 20:04:01 -07:00
|
|
|
\\error: TheSkyIsFalling
|
2019-05-27 17:07:05 -07:00
|
|
|
\\
|
|
|
|
,
|
2019-09-03 07:05:19 -07:00
|
|
|
// release-small
|
2019-09-07 20:04:01 -07:00
|
|
|
\\error: TheSkyIsFalling
|
2019-05-27 17:07:05 -07:00
|
|
|
\\
|
|
|
|
},
|
|
|
|
);
|
|
|
|
cases.addCase(
|
|
|
|
"try return",
|
|
|
|
source_try_return,
|
2019-09-03 07:05:19 -07:00
|
|
|
[_][]const u8{
|
|
|
|
// debug
|
2019-09-07 20:04:01 -07:00
|
|
|
\\error: TheSkyIsFalling
|
2019-05-27 17:07:05 -07:00
|
|
|
\\source.zig:4:5: [address] in _foo (test.o)
|
|
|
|
\\source.zig:8:5: [address] in _main.0 (test.o)
|
|
|
|
\\
|
|
|
|
,
|
2019-09-03 07:05:19 -07:00
|
|
|
// release-safe
|
2019-09-07 20:04:01 -07:00
|
|
|
\\error: TheSkyIsFalling
|
2019-05-27 17:07:05 -07:00
|
|
|
\\source.zig:4:5: [address] in _main (test.o)
|
|
|
|
\\source.zig:8:5: [address] in _main (test.o)
|
|
|
|
\\
|
|
|
|
,
|
2019-09-03 07:05:19 -07:00
|
|
|
// release-fast
|
2019-09-07 20:04:01 -07:00
|
|
|
\\error: TheSkyIsFalling
|
2019-05-27 17:07:05 -07:00
|
|
|
\\
|
|
|
|
,
|
2019-09-03 07:05:19 -07:00
|
|
|
// release-small
|
2019-09-07 20:04:01 -07:00
|
|
|
\\error: TheSkyIsFalling
|
2019-05-27 17:07:05 -07:00
|
|
|
\\
|
|
|
|
},
|
|
|
|
);
|
|
|
|
cases.addCase(
|
|
|
|
"try try return return",
|
|
|
|
source_try_try_return_return,
|
2019-09-03 07:05:19 -07:00
|
|
|
[_][]const u8{
|
|
|
|
// debug
|
2019-09-07 20:04:01 -07:00
|
|
|
\\error: TheSkyIsFalling
|
2019-05-27 17:07:05 -07:00
|
|
|
\\source.zig:12:5: [address] in _make_error (test.o)
|
|
|
|
\\source.zig:8:5: [address] in _bar (test.o)
|
|
|
|
\\source.zig:4:5: [address] in _foo (test.o)
|
|
|
|
\\source.zig:16:5: [address] in _main.0 (test.o)
|
|
|
|
\\
|
|
|
|
,
|
2019-09-03 07:05:19 -07:00
|
|
|
// release-safe
|
2019-09-07 20:04:01 -07:00
|
|
|
\\error: TheSkyIsFalling
|
2019-05-27 17:07:05 -07:00
|
|
|
\\source.zig:12:5: [address] in _main (test.o)
|
|
|
|
\\source.zig:8:5: [address] in _main (test.o)
|
|
|
|
\\source.zig:4:5: [address] in _main (test.o)
|
|
|
|
\\source.zig:16:5: [address] in _main (test.o)
|
|
|
|
\\
|
|
|
|
,
|
2019-09-03 07:05:19 -07:00
|
|
|
// release-fast
|
2019-09-07 20:04:01 -07:00
|
|
|
\\error: TheSkyIsFalling
|
2019-05-27 17:07:05 -07:00
|
|
|
\\
|
|
|
|
,
|
2019-09-03 07:05:19 -07:00
|
|
|
// release-small
|
2019-09-07 20:04:01 -07:00
|
|
|
\\error: TheSkyIsFalling
|
2019-05-27 17:07:05 -07:00
|
|
|
\\
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
.windows => {
|
|
|
|
cases.addCase(
|
|
|
|
"return",
|
|
|
|
source_return,
|
2019-09-03 07:05:19 -07:00
|
|
|
[_][]const u8{
|
|
|
|
// debug
|
2019-09-07 20:04:01 -07:00
|
|
|
\\error: TheSkyIsFalling
|
2019-05-27 17:07:05 -07:00
|
|
|
\\source.zig:4:5: [address] in main (test.obj)
|
|
|
|
\\
|
|
|
|
,
|
2019-09-03 07:05:19 -07:00
|
|
|
// release-safe
|
|
|
|
// --disabled-- results in segmenetation fault
|
|
|
|
"",
|
|
|
|
// release-fast
|
2019-09-07 20:04:01 -07:00
|
|
|
\\error: TheSkyIsFalling
|
2019-05-27 17:07:05 -07:00
|
|
|
\\
|
|
|
|
,
|
2019-09-03 07:05:19 -07:00
|
|
|
// release-small
|
2019-09-07 20:04:01 -07:00
|
|
|
\\error: TheSkyIsFalling
|
2019-05-27 17:07:05 -07:00
|
|
|
\\
|
|
|
|
},
|
|
|
|
);
|
|
|
|
cases.addCase(
|
|
|
|
"try return",
|
|
|
|
source_try_return,
|
2019-09-03 07:05:19 -07:00
|
|
|
[_][]const u8{
|
|
|
|
// debug
|
|
|
|
\\error: TheSkyIsFalling
|
2019-05-27 17:07:05 -07:00
|
|
|
\\source.zig:4:5: [address] in foo (test.obj)
|
|
|
|
\\source.zig:8:5: [address] in main (test.obj)
|
|
|
|
\\
|
|
|
|
,
|
2019-09-03 07:05:19 -07:00
|
|
|
// release-safe
|
|
|
|
// --disabled-- results in segmenetation fault
|
|
|
|
"",
|
|
|
|
// release-fast
|
2019-09-07 20:04:01 -07:00
|
|
|
\\error: TheSkyIsFalling
|
2019-05-27 17:07:05 -07:00
|
|
|
\\
|
|
|
|
,
|
2019-09-03 07:05:19 -07:00
|
|
|
// release-small
|
2019-09-07 20:04:01 -07:00
|
|
|
\\error: TheSkyIsFalling
|
2019-05-27 17:07:05 -07:00
|
|
|
\\
|
|
|
|
},
|
|
|
|
);
|
|
|
|
cases.addCase(
|
|
|
|
"try try return return",
|
|
|
|
source_try_try_return_return,
|
2019-09-03 07:05:19 -07:00
|
|
|
[_][]const u8{
|
|
|
|
// debug
|
|
|
|
\\error: TheSkyIsFalling
|
2019-05-27 17:07:05 -07:00
|
|
|
\\source.zig:12:5: [address] in make_error (test.obj)
|
|
|
|
\\source.zig:8:5: [address] in bar (test.obj)
|
|
|
|
\\source.zig:4:5: [address] in foo (test.obj)
|
|
|
|
\\source.zig:16:5: [address] in main (test.obj)
|
|
|
|
\\
|
|
|
|
,
|
2019-09-03 07:05:19 -07:00
|
|
|
// release-safe
|
|
|
|
// --disabled-- results in segmenetation fault
|
|
|
|
"",
|
|
|
|
// release-fast
|
2019-09-07 20:04:01 -07:00
|
|
|
\\error: TheSkyIsFalling
|
2019-05-27 17:07:05 -07:00
|
|
|
\\
|
|
|
|
,
|
2019-09-03 07:05:19 -07:00
|
|
|
// release-small
|
2019-09-07 20:04:01 -07:00
|
|
|
\\error: TheSkyIsFalling
|
2019-05-27 17:07:05 -07:00
|
|
|
\\
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
else => {},
|
|
|
|
}
|
2019-09-07 20:04:01 -07:00
|
|
|
// zig fmt: off
|
2019-05-27 17:07:05 -07:00
|
|
|
}
|