Files
zig/test/cases/compile_errors/panic_has_source_location.zig
mlugg 8f3ccbbe36 Sema: provide source location when analyzing panic handler
The panic handler decl_val was previously given a `unneeded` source
location, which was then added to the reference trace, resulting in a
crash if the source location was used in the reference trace. This
commit makes two trivial changes:

* Don't add unneeded source locations to the ref table (panic in debug, silently ignore in release)
* Pass a real source location when analyzing the panic handler
2023-08-14 11:43:21 -07:00

18 lines
381 B
Zig

const std = @import("std");
export fn foo() void {
// This should appear in the reference trace
// (and definitely shouldn't crash due to an unneeded source location!)
@panic("oh no");
}
pub fn panic(_: []const u8, _: ?*std.builtin.StackTrace, _: ?usize) noreturn {
@compileError("panic");
}
// error
// backend=stage2
// target=native
//
// :10:5: error: panic