aboutsummaryrefslogtreecommitdiff
path: root/src/codegen
diff options
context:
space:
mode:
authorCody Tapscott <topolarity@tapscott.me>2022-09-12 23:09:14 -0700
committerCody Tapscott <topolarity@tapscott.me>2022-10-21 10:44:19 -0700
commit0c3a50fe1c1370c975d7de1f2f00458b4a3ec299 (patch)
tree0e282d7a4702780f75ccebba7b9e7937d4e59985 /src/codegen
parenteda3eb1561ec9a68e692821d5de71d03e6f50d42 (diff)
downloadzig-0c3a50fe1c1370c975d7de1f2f00458b4a3ec299.tar.gz
zig-0c3a50fe1c1370c975d7de1f2f00458b4a3ec299.zip
stage2: Do not pop error trace if result is an error
This allows for errors to be "re-thrown" by yielding any error as the result of a catch block. For example: ```zig fn errorable() !void { return error.FallingOutOfPlane; } fn foo(have_parachute: bool) !void { return errorable() catch |err| b: { if (have_parachute) { // error trace will include the call to errorable() break :b error.NoParachute; } else { return; } }; } pub fn main() !void { // Anything that returns a non-error does not pollute the error trace. try foo(true); // This error trace will still include errorable(), whose error was "re-thrown" by foo() try foo(false); } ``` This is piece (2/3) of https://github.com/ziglang/zig/issues/1923#issuecomment-1218495574
Diffstat (limited to 'src/codegen')
0 files changed, 0 insertions, 0 deletions