Open Inve1951 opened 5 months ago
I thought this was intentional behavior?
Possibly related/the same, but with the inline function being the inner function and zig not showing which line the error occurred at.
inline fn inner() !void {
return error.InvalidVal;
}
fn outer() !void {
try inner();
}
pub fn main() !void {
try outer();
}
$ zig build-exe -O Debug main.zig
$ ./main
error: InvalidVal
<snip>/main.zig:6:5: 0x1033b86 in outer (main
)
try inner();
^
<snip>/main.zig:10:5: 0x1033ca3 in main (main
)
try outer();
^
Without marking inner()
as inline
:
error: InvalidVal
<snip>/main.zig:2:5: 0x1033ba8 in inner (main
)
return error.InvalidVal;
^
<snip>/main.zig:6:5: 0x1033cb3 in outer (main
)
try inner();
^
<snip>/main.zig:10:5: 0x1033cf3 in main (main
)
try outer();
^
When I do something similiar (AFAICT) in C, compiling with clang, gdb can tell me just fine where the fault occurs.
This makes debugging failing tests where a big inlined function is involved unnecessarily cumbersome (imo), as zig build
won't print the error which was returned. zig build
only prints that the test failed and which inlined function triggers the error. zig test
will print the error name at least, but I guess that's a separate issue ticket/matter:
$ zig-nightly build test -Doptimize=Debug -freference-trace
test
└─ run test 0/1 passed, 1 failed
error: 'main.test_0' failed: <snip>/zig-linux-x86_64-0.12.0-dev.3439+31a7f 22b8/lib/compiler/main.zig:6:5: 0x10396e6 in outer (test)
<snip>/zig-linux-x86_64-0.12.0-dev.3439+31a7f22b8/lib/compiler/main.zig:14:5: 0x1039803 in test_0 (test)
error: while executing test 'main.test_0', the following test command failed:
<snip>/zig-cache/o/3b3fafdd763ff5442eb3edb769
9bc0f6/test --listen=-
Build Summary: 1/3 steps succeeded; 1 failed; 0/1 tests passed; 1 failed (disable with --summary none)
test transitive failure
└─ run test 0/1 passed, 1 failed
error: the following build command failed with exit code 1:
<snip>/zig-cache/o/d15bdc5fa3ae95c2118b5028b1
7ee5f2/build <snip>/zig-linux-x86_64-0.12.0-dev.3439+31a7f22b8/zig <snip>/.cache/zig --seed 0x2551e4f8 -Zf7a43c2259b1da74 test -Doptimize=Debug -freference-trace
Possibly related https://github.com/ziglang/zig/issues/18237
Zig Version
0.12.0-dev.3381+7057bffc1
Steps to Reproduce and Observed Behavior
Scenario 1:
Output:
Scenario 2:
Output:
Expected Behavior
Expected output is as if the function wasn't
inline
.Expected 1:
Expected 2: