This fails to compile. Seems like the compiler does not transfer the correct errorset into the errdefer handler:
fn foo(val: bool) !void {
// error: expected type 'error{Truth}', found 'error{Justice}'
errdefer |err| switch (err) {
error.Truth => {},
error.Justice => {},
};
if (val) {
return error.Truth;
} else {
return error.Justice;
}
}
Even more bizarrely, sometimes the errdefer receives an error union:
fn foo(val: bool) error{Truth,Justice}!void {
// error: invalid switch target type 'error:1:19!void'
errdefer |err| switch (err) {};
return if (val) error.Truth else error.Justice;
}
This fails to compile. Seems like the compiler does not transfer the correct errorset into the
errdeferhandler:Even more bizarrely, sometimes the errdefer receives an error union: