| author | |
| committer | |
| log | 135cb529def1d77e2e7e3edb641c37fb0cb47f2e |
| tree | 3630e4cf3afd2df6b6e3e851a98af21fc54ee5f9 |
| parent | ec3ed92f48097c70791dda9e5cf20086776d26ce |
2 files changed, 14 insertions(+), 1 deletions(-)
src/AstGen.zig+1-1| ... | @@ -4912,7 +4912,7 @@ fn tryExpr( | ... | @@ -4912,7 +4912,7 @@ fn tryExpr( |
| 4912 | .ref => .ref, | 4912 | .ref => .ref, |
| 4913 | else => .none, | 4913 | else => .none, |
| 4914 | }; | 4914 | }; |
| 4915 | const err_ops = switch (rl) { | 4915 | const err_ops = switch (operand_rl) { |
| 4916 | // zig fmt: off | 4916 | // zig fmt: off |
| 4917 | .ref => [3]Zir.Inst.Tag{ .is_non_err_ptr, .err_union_code_ptr, .err_union_payload_unsafe_ptr }, | 4917 | .ref => [3]Zir.Inst.Tag{ .is_non_err_ptr, .err_union_code_ptr, .err_union_payload_unsafe_ptr }, |
| 4918 | else => [3]Zir.Inst.Tag{ .is_non_err, .err_union_code, .err_union_payload_unsafe }, | 4918 | else => [3]Zir.Inst.Tag{ .is_non_err, .err_union_code, .err_union_payload_unsafe }, |
test/stage2/cbe.zig+13| ... | @@ -501,6 +501,19 @@ pub fn addCases(ctx: *TestContext) !void { | ... | @@ -501,6 +501,19 @@ pub fn addCases(ctx: *TestContext) !void { |
| 501 | \\ return 69 - i; | 501 | \\ return 69 - i; |
| 502 | \\} | 502 | \\} |
| 503 | , ""); | 503 | , ""); |
| 504 | case.addCompareOutput( | ||
| 505 | \\const E = error{e}; | ||
| 506 | \\const S = struct { x: u32 }; | ||
| 507 | \\fn f() E!u32 { | ||
| 508 | \\ const x = (try @as(E!S, S{ .x = 1 })).x; | ||
| 509 | \\ return x; | ||
| 510 | \\} | ||
| 511 | \\pub export fn main() c_int { | ||
| 512 | \\ const x = f() catch @as(u32, 0); | ||
| 513 | \\ if (x != 1) unreachable; | ||
| 514 | \\ return 0; | ||
| 515 | \\} | ||
| 516 | , ""); | ||
| 504 | } | 517 | } |
| 505 | 518 | ||
| 506 | { | 519 | { |