fn bar() error{ Bar, Foo }!void {
return error.Bar;
}
fn foo() error{Foo}!void {
bar() catch |err| switch (err) {
error.Bar => {},
inline else => |e| return e,
};
}
test {
try foo();
}
> zig test foo.zig
foo.zig:8:35: error: expected type 'error{Foo}!void', found 'error{Bar,Foo}'
inline else => |e| return e,
^
foo.zig:8:35: note: 'error.Bar' not a member of destination error set
foo.zig:5:20: note: function return type declared here
fn foo() error{Foo}!void {
~~~~~~~~~~^~~~~
I thought this would recognize that the e can’t be error.Bar. What should I do in a situation like this?