| ... | ... | @@ -3594,11 +3594,13 @@ const DeclGen = struct { |
| 3594 | 3594 | return result_id; |
| 3595 | 3595 | } |
| 3596 | 3596 | |
| 3597 | | const is_non_null_id = if (optional_ty.hasRuntimeBitsIgnoreComptime(mod)) |
| 3597 | const is_non_null_id = if (payload_ty.hasRuntimeBitsIgnoreComptime(mod)) |
| 3598 | 3598 | try self.extractField(Type.bool, operand_id, 1) |
| 3599 | 3599 | else |
| 3600 | 3600 | // Optional representation is bool indicating whether the optional is set |
| 3601 | | operand_id; |
| 3601 | // Optionals with no payload are represented as an (indirect) bool, so convert |
| 3602 | // it back to the direct bool here. |
| 3603 | try self.convertToDirect(Type.bool, operand_id); |
| 3602 | 3604 | |
| 3603 | 3605 | return switch (pred) { |
| 3604 | 3606 | .is_null => blk: { |
| ... | ... | @@ -3677,17 +3679,19 @@ const DeclGen = struct { |
| 3677 | 3679 | const payload_ty = self.typeOf(ty_op.operand); |
| 3678 | 3680 | |
| 3679 | 3681 | if (!payload_ty.hasRuntimeBitsIgnoreComptime(mod)) { |
| 3680 | | return try self.constBool(true, .direct); |
| 3682 | return try self.constBool(true, .indirect); |
| 3681 | 3683 | } |
| 3682 | 3684 | |
| 3683 | 3685 | const operand_id = try self.resolve(ty_op.operand); |
| 3686 | |
| 3684 | 3687 | const optional_ty = self.typeOfIndex(inst); |
| 3685 | 3688 | if (optional_ty.optionalReprIsPayload(mod)) { |
| 3686 | 3689 | return operand_id; |
| 3687 | 3690 | } |
| 3688 | 3691 | |
| 3689 | 3692 | const optional_ty_ref = try self.resolveType(optional_ty, .direct); |
| 3690 | | const members = [_]IdRef{ operand_id, try self.constBool(true, .indirect) }; |
| 3693 | const payload_id = try self.convertToIndirect(payload_ty, operand_id); |
| 3694 | const members = [_]IdRef{ payload_id, try self.constBool(true, .indirect) }; |
| 3691 | 3695 | return try self.constructStruct(optional_ty_ref, &members); |
| 3692 | 3696 | } |
| 3693 | 3697 | |