Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad error trace #11593

Closed
danielchasehooper opened this issue May 5, 2022 · 1 comment
Closed

Bad error trace #11593

danielchasehooper opened this issue May 5, 2022 · 1 comment
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@danielchasehooper
Copy link
Contributor

Zig Version

0.10.0-dev.2083+13d1798ea

Steps to Reproduce

run zig test phantomErrorTrace.zig

// phantomErrorTrace.zig
const std = @import("std");

fn alwaysErrors() !void {
    return error.BUG_ThisErrorShouldNotAppearInAnyTrace;
}

test "test expected error" {
    try std.testing.expectError(error.BUG_ThisErrorShouldNotAppearInAnyTrace, alwaysErrors());
}

test "trigger error trace" {
    return error.WeExpectToSeeThisInTheTrace;
}

Expected Behavior

should only see error trace for the second test

1/2 test "test expected error"... OK
2/2 test "trigger error trace"... FAIL (WeExpectToSeeThisInTheTrace)
FAIL (WeExpectToSeeThisInTheTrace)
/Users/daniel/Developer/zigtests/phantomerrortrace.zig:14:5: 0x1005a992f in test "trigger error trace" (test)
    return error.WeExpectToSeeThisInTheTrace;
    ^
1 passed; 0 skipped; 1 failed.

Actual Behavior

Error trace from the first test appears in the error trace for the second test

1/2 test "test expected error"... OK
2/2 test "trigger error trace"... FAIL (WeExpectToSeeThisInTheTrace)
FAIL (WeExpectToSeeThisInTheTrace)
/Users/daniel/Developer/zigtests/phantomerrortrace.zig:6:5: 0x10085dce7 in alwaysErrors (test)
    return error.BUG_ThisErrorShouldNotAppearInAnyTrace;
    ^
/Users/daniel/Developer/zigtests/phantomerrortrace.zig:14:5: 0x10085cd3b in test "trigger error trace" (test)
    return error.WeExpectToSeeThisInTheTrace;
    ^
1 passed; 0 skipped; 1 failed.
@danielchasehooper danielchasehooper added the bug Observed behavior contradicts documented or intended behavior label May 5, 2022
@squeek502
Copy link
Collaborator

Very likely to be a duplicate of #1923

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

3 participants