| author | |
| committer | |
| log | 03b1fbe50d302cdb961661c10bb51699b4dcbaf2 |
| tree | 9419580acba06a94ccae2019bbe0631b39f54624 |
| parent | 1f748fe42662da3ee2c977ba638a714e15acb433 |
3 files changed, 17 insertions(+), 3 deletions(-)
src/codegen/c.zig+3-2| ... | @@ -3618,8 +3618,9 @@ fn airIsErr( | ... | @@ -3618,8 +3618,9 @@ fn airIsErr( |
| 3618 | const operand = try f.resolveInst(un_op); | 3618 | const operand = try f.resolveInst(un_op); |
| 3619 | const operand_ty = f.air.typeOf(un_op); | 3619 | const operand_ty = f.air.typeOf(un_op); |
| 3620 | const local = try f.allocLocal(Type.initTag(.bool), .Const); | 3620 | const local = try f.allocLocal(Type.initTag(.bool), .Const); |
| 3621 | const payload_ty = operand_ty.errorUnionPayload(); | 3621 | const err_union_ty = if (is_ptr) operand_ty.childType() else operand_ty; |
| 3622 | const error_ty = operand_ty.errorUnionSet(); | 3622 | const payload_ty = err_union_ty.errorUnionPayload(); |
| 3623 | const error_ty = err_union_ty.errorUnionSet(); | ||
| 3623 | 3624 | ||
| 3624 | try writer.writeAll(" = "); | 3625 | try writer.writeAll(" = "); |
| 3625 | 3626 |
src/codegen/llvm.zig+2-1| ... | @@ -5693,7 +5693,8 @@ pub const FuncGen = struct { | ... | @@ -5693,7 +5693,8 @@ pub const FuncGen = struct { |
| 5693 | 5693 | ||
| 5694 | const un_op = self.air.instructions.items(.data)[inst].un_op; | 5694 | const un_op = self.air.instructions.items(.data)[inst].un_op; |
| 5695 | const operand = try self.resolveInst(un_op); | 5695 | const operand = try self.resolveInst(un_op); |
| 5696 | const err_union_ty = self.air.typeOf(un_op); | 5696 | const operand_ty = self.air.typeOf(un_op); |
| 5697 | const err_union_ty = if (operand_is_ptr) operand_ty.childType() else operand_ty; | ||
| 5697 | const payload_ty = err_union_ty.errorUnionPayload(); | 5698 | const payload_ty = err_union_ty.errorUnionPayload(); |
| 5698 | const err_set_ty = try self.dg.lowerType(Type.initTag(.anyerror)); | 5699 | const err_set_ty = try self.dg.lowerType(Type.initTag(.anyerror)); |
| 5699 | const zero = err_set_ty.constNull(); | 5700 | const zero = err_set_ty.constNull(); |
test/behavior/error.zig+12| ... | @@ -724,3 +724,15 @@ test "simple else prong allowed even when all errors handled" { | ... | @@ -724,3 +724,15 @@ test "simple else prong allowed even when all errors handled" { |
| 724 | }; | 724 | }; |
| 725 | try expect(value == 255); | 725 | try expect(value == 255); |
| 726 | } | 726 | } |
| 727 | |||
| 728 | test { | ||
| 729 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | ||
| 730 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | ||
| 731 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | ||
| 732 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO | ||
| 733 | |||
| 734 | var err_union: anyerror!u8 = 15; | ||
| 735 | |||
| 736 | const payload_ptr = &(err_union catch unreachable); | ||
| 737 | try expect(payload_ptr.* == 15); | ||
| 738 | } |