| ... | ... | @@ -679,7 +679,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void { |
| 679 | 679 | |
| 680 | 680 | .wrap_optional => @panic("TODO try self.airWrapOptional(inst)"), |
| 681 | 681 | .wrap_errunion_payload => @panic("TODO try self.airWrapErrUnionPayload(inst)"), |
| 682 | | .wrap_errunion_err => @panic("TODO try self.airWrapErrUnionErr(inst)"), |
| 682 | .wrap_errunion_err => try self.airWrapErrUnionErr(inst), |
| 683 | 683 | |
| 684 | 684 | .wasm_memory_size => unreachable, |
| 685 | 685 | .wasm_memory_grow => unreachable, |
| ... | ... | @@ -1851,6 +1851,20 @@ fn airUnwrapErrPayload(self: *Self, inst: Air.Inst.Index) !void { |
| 1851 | 1851 | return self.finishAir(inst, result, .{ ty_op.operand, .none, .none }); |
| 1852 | 1852 | } |
| 1853 | 1853 | |
| 1854 | /// E to E!T |
| 1855 | fn airWrapErrUnionErr(self: *Self, inst: Air.Inst.Index) !void { |
| 1856 | const ty_op = self.air.instructions.items(.data)[inst].ty_op; |
| 1857 | const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: { |
| 1858 | const error_union_ty = self.air.getRefType(ty_op.ty); |
| 1859 | const payload_ty = error_union_ty.errorUnionPayload(); |
| 1860 | const mcv = try self.resolveInst(ty_op.operand); |
| 1861 | if (!payload_ty.hasRuntimeBits()) break :result mcv; |
| 1862 | |
| 1863 | return self.fail("TODO implement wrap errunion error for non-empty payloads", .{}); |
| 1864 | }; |
| 1865 | return self.finishAir(inst, result, .{ ty_op.operand, .none, .none }); |
| 1866 | } |
| 1867 | |
| 1854 | 1868 | // Common helper functions |
| 1855 | 1869 | |
| 1856 | 1870 | /// Adds a Type to the .debug_info at the current position. The bytes will be populated later, |