diff options
| -rw-r--r-- | src/AstGen.zig | 2 | ||||
| -rw-r--r-- | test/stage2/cbe.zig | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/AstGen.zig b/src/AstGen.zig index c76b421368..6445f6ed11 100644 --- a/src/AstGen.zig +++ b/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 }, diff --git a/test/stage2/cbe.zig b/test/stage2/cbe.zig index a6e81a5f5c..54ff136512 100644 --- a/test/stage2/cbe.zig +++ b/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; + \\} + , ""); } { |
