authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-08-05 23:20:53-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-08-05 23:20:53-07:00
logc7dc451a2a06a0ade0bb44a48cb6e5cde6e237df
tree2b3f5e06da3918326b61eeb4f10a11d8cf7668ed
parent786e238a7f1034a09bc0471b3796051abb874e14

stage2: more debuggable panics

For now these errors are handled via `@panic` rather than `unreachable`. These are relatively likely bugs to occur at this early stage of development, and handling them as panics lets us ship release builds of the compiler without worrying about undefined behavior. Furthermore, in stage1, `@panic` is implemented to include an error return trace, while `unreachable` is not. In this case, the error return traces are extremely helpful in debugging the compiler.

1 files changed, 2 insertions(+), 2 deletions(-)

src/Module.zig+2-2
...@@ -3792,8 +3792,8 @@ pub fn analyzeFnBody(mod: *Module, decl: *Decl, func: *Fn) SemaError!Air {...@@ -3792,8 +3792,8 @@ pub fn analyzeFnBody(mod: *Module, decl: *Decl, func: *Fn) SemaError!Air {
3792 log.debug("set {s} to in_progress", .{decl.name});3792 log.debug("set {s} to in_progress", .{decl.name});
37933793
3794 _ = sema.analyzeBody(&inner_block, fn_info.body) catch |err| switch (err) {3794 _ = sema.analyzeBody(&inner_block, fn_info.body) catch |err| switch (err) {
3795 error.NeededSourceLocation => unreachable,3795 error.NeededSourceLocation => @panic("zig compiler bug: NeededSourceLocation"),
3796 error.GenericPoison => unreachable,3796 error.GenericPoison => @panic("zig compiler bug: GenericPoison"),
3797 else => |e| return e,3797 else => |e| return e,
3798 };3798 };
37993799