zig
zig copied to clipboard
Reference trace points to the wrong call site
Zig Version
0.12.0-dev.3412+54c08579e
Steps to Reproduce and Observed Behavior
This code has the wrong error message:
const std = @import("std");
pub fn main() void {
// This causes a compile error...
foo(true);
}
pub fn panic(_: []const u8, _: ?*std.builtin.StackTrace, _: ?usize) noreturn {
// but the reference trace points here!
foo(false);
unreachable;
}
pub inline fn foo(should_compile_error: bool) void {
return bar(should_compile_error);
}
pub fn bar(comptime should_compile_error: bool) void {
if (should_compile_error) @compileError("bad");
}
The error trace is
src\main.zig:19:31: error: bad
if (should_compile_error) @compileError("bad");
^~~~~~~~~~~~~~~~~~~~
referenced by:
foo: src\main.zig:15:15
panic: src\main.zig:10:5
Removing the call to foo in panic results in the correct error trace:
src\main.zig:19:31: error: bad
if (should_compile_error) @compileError("bad");
^~~~~~~~~~~~~~~~~~~~
referenced by:
foo: src\main.zig:15:15
main: src\main.zig:5:5
callMain: C:\Program Files\zigup.windows-latest-x86_64\zig\0.12.0-dev.3412+54c08579e\files\lib\std\start.zig:501:17
WinStartup: C:\Program Files\zigup.windows-latest-x86_64\zig\0.12.0-dev.3412+54c08579e\files\lib\std\start.zig:350:45
Expected Behavior
The error should point to the call site of foo in main, not the one in panic.