Source
pub inline fn callMain() u8 {
const ReturnType = @typeInfo(@TypeOf(root.main)).@"fn".return_type.?;
switch (ReturnType) {
void => {
root.main();
return 0;
},
noreturn, u8 => {
return root.main();
},
else => {
if (@typeInfo(ReturnType) != .error_union) @compileError(bad_main_ret);
const result = root.main() catch |err| {
if (builtin.zig_backend == .stage2_riscv64) {
std.debug.print("error: failed with error\n", .{});
return 1;
}
std.log.err("{s}", .{@errorName(err)});
if (@errorReturnTrace()) |trace| {
std.debug.dumpStackTrace(trace.*);
}
return 1;
};
return switch (@TypeOf(result)) {
void => 0,
u8 => result,
else => @compileError(bad_main_ret),
};
},
}
}