sema: fix error_return_trace_index handling in zirCondBr

This commit is contained in:
Pavel Verigo
2025-12-05 02:34:51 +01:00
committed by Alex Rønne Petersen
parent a21d9408a3
commit cc099afca5
2 changed files with 26 additions and 3 deletions
+19
View File
@@ -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);
}