Skip to content

Bad error trace #11593

Description

@danielchasehooper

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions