zig/test/cases/issue_30095.zig

28 lines
444 B
Zig

var e: anyerror = undefined;
const E = error{Err};
extern fn bar() u8;
fn foo() E!u8 {
const x = bar();
return if (x != 0) E.Err else 0;
}
pub fn main() !void {
var val: bool = false;
_ = &val;
if (val) {
const maybe = foo();
_ = maybe catch {};
} else {
if (foo()) |byte| {
_ = byte;
} else |err| {
e = err;
}
}
}
// compile
// output_mode=Obj
//