mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-27 19:09:47 +03:00
sema: fix error_return_trace_index handling in zirCondBr
This commit is contained in:
committed by
Alex Rønne Petersen
parent
a21d9408a3
commit
cc099afca5
@@ -1090,3 +1090,22 @@ test "compare error union to error set" {
|
||||
try S.doTheTest(0);
|
||||
try comptime S.doTheTest(0);
|
||||
}
|
||||
|
||||
test "'if' ignores error via local while 'else' ignores error directly" {
|
||||
const S = struct {
|
||||
/// This function is intentionally fallible despite never returning an
|
||||
/// error so that it participates in error return tracing.
|
||||
fn testOne(cond: bool) !void {
|
||||
if (cond) {
|
||||
const result = notError();
|
||||
result catch {};
|
||||
} else {
|
||||
notError() catch {};
|
||||
}
|
||||
}
|
||||
fn notError() error{E}!void {}
|
||||
};
|
||||
|
||||
try S.testOne(false);
|
||||
try S.testOne(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user