Commit 135cb529de
Changed files (2)
src
test
stage2
src/AstGen.zig
@@ -4912,7 +4912,7 @@ fn tryExpr(
.ref => .ref,
else => .none,
};
- const err_ops = switch (rl) {
+ const err_ops = switch (operand_rl) {
// zig fmt: off
.ref => [3]Zir.Inst.Tag{ .is_non_err_ptr, .err_union_code_ptr, .err_union_payload_unsafe_ptr },
else => [3]Zir.Inst.Tag{ .is_non_err, .err_union_code, .err_union_payload_unsafe },
test/stage2/cbe.zig
@@ -501,6 +501,19 @@ pub fn addCases(ctx: *TestContext) !void {
\\ return 69 - i;
\\}
, "");
+ case.addCompareOutput(
+ \\const E = error{e};
+ \\const S = struct { x: u32 };
+ \\fn f() E!u32 {
+ \\ const x = (try @as(E!S, S{ .x = 1 })).x;
+ \\ return x;
+ \\}
+ \\pub export fn main() c_int {
+ \\ const x = f() catch @as(u32, 0);
+ \\ if (x != 1) unreachable;
+ \\ return 0;
+ \\}
+ , "");
}
{