diff options
| author | Pavel Verigo <paul.verigo@gmail.com> | 2025-12-05 02:34:51 +0100 |
|---|---|---|
| committer | Alex Rønne Petersen <alex@alexrp.com> | 2025-12-07 07:20:59 +0100 |
| commit | cc099afca557ae427261ab0c5c733738d9d87782 (patch) | |
| tree | 66872dd203ddadb5c22553795b51e5535ade72a0 /test/behavior/error.zig | |
| parent | a21d9408a3ab20d90b4f410695eb598387afd8d3 (diff) | |
| download | zig-cc099afca557ae427261ab0c5c733738d9d87782.tar.gz zig-cc099afca557ae427261ab0c5c733738d9d87782.zip | |
sema: fix error_return_trace_index handling in zirCondBr
Diffstat (limited to 'test/behavior/error.zig')
| -rw-r--r-- | test/behavior/error.zig | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/behavior/error.zig b/test/behavior/error.zig index aa39b685ca..d74a7668a9 100644 --- a/test/behavior/error.zig +++ b/test/behavior/error.zig @@ -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); +} |
