| ... | ... | @@ -18576,7 +18576,6 @@ static IrInstGen *ir_resolve_result(IrAnalyze *ira, IrInst *suspend_source_instr |
| 18576 | 18576 | ResultLoc *result_loc_pass1, ZigType *value_type, IrInstGen *value, bool force_runtime, |
| 18577 | 18577 | bool allow_discard) |
| 18578 | 18578 | { |
| 18579 | | Error err; |
| 18580 | 18579 | if (!allow_discard && result_loc_is_discard(result_loc_pass1)) { |
| 18581 | 18580 | result_loc_pass1 = no_result_loc(); |
| 18582 | 18581 | } |
| ... | ... | @@ -18672,32 +18671,22 @@ static IrInstGen *ir_resolve_result(IrAnalyze *ira, IrInst *suspend_source_instr |
| 18672 | 18671 | { |
| 18673 | 18672 | bool same_comptime_repr = types_have_same_zig_comptime_repr(ira->codegen, actual_elem_type, value_type); |
| 18674 | 18673 | if (!same_comptime_repr) { |
| 18675 | | bool has_bits; |
| 18676 | | if ((err = type_has_bits2(ira->codegen, value_type, &has_bits))) |
| 18677 | | return ira->codegen->invalid_inst_gen; |
| 18678 | | if (has_bits) { |
| 18679 | | result_loc_pass1->written = false; |
| 18680 | | return ir_analyze_unwrap_optional_payload(ira, suspend_source_instr, result_loc, false, true); |
| 18681 | | } |
| 18674 | result_loc_pass1->written = false; |
| 18675 | return ir_analyze_unwrap_optional_payload(ira, suspend_source_instr, result_loc, false, true); |
| 18682 | 18676 | } |
| 18683 | 18677 | } else if (actual_elem_type->id == ZigTypeIdErrorUnion && value_type->id != ZigTypeIdErrorUnion) { |
| 18684 | | bool has_bits; |
| 18685 | | if ((err = type_has_bits2(ira->codegen, value_type, &has_bits))) |
| 18686 | | return ira->codegen->invalid_inst_gen; |
| 18687 | | if (has_bits) { |
| 18688 | | if (value_type->id == ZigTypeIdErrorSet) { |
| 18689 | | return ir_analyze_unwrap_err_code(ira, suspend_source_instr, result_loc, true); |
| 18678 | if (value_type->id == ZigTypeIdErrorSet) { |
| 18679 | return ir_analyze_unwrap_err_code(ira, suspend_source_instr, result_loc, true); |
| 18680 | } else { |
| 18681 | IrInstGen *unwrapped_err_ptr = ir_analyze_unwrap_error_payload(ira, suspend_source_instr, |
| 18682 | result_loc, false, true); |
| 18683 | ZigType *actual_payload_type = actual_elem_type->data.error_union.payload_type; |
| 18684 | if (actual_payload_type->id == ZigTypeIdOptional && value_type->id != ZigTypeIdOptional && |
| 18685 | value_type->id != ZigTypeIdNull) |
| 18686 | { |
| 18687 | return ir_analyze_unwrap_optional_payload(ira, suspend_source_instr, unwrapped_err_ptr, false, true); |
| 18690 | 18688 | } else { |
| 18691 | | IrInstGen *unwrapped_err_ptr = ir_analyze_unwrap_error_payload(ira, suspend_source_instr, |
| 18692 | | result_loc, false, true); |
| 18693 | | ZigType *actual_payload_type = actual_elem_type->data.error_union.payload_type; |
| 18694 | | if (actual_payload_type->id == ZigTypeIdOptional && value_type->id != ZigTypeIdOptional && |
| 18695 | | value_type->id != ZigTypeIdNull) |
| 18696 | | { |
| 18697 | | return ir_analyze_unwrap_optional_payload(ira, suspend_source_instr, unwrapped_err_ptr, false, true); |
| 18698 | | } else { |
| 18699 | | return unwrapped_err_ptr; |
| 18700 | | } |
| 18689 | return unwrapped_err_ptr; |
| 18701 | 18690 | } |
| 18702 | 18691 | } |
| 18703 | 18692 | } |
| ... | ... | @@ -22215,14 +22204,8 @@ static IrInstGen *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInst* sou |
| 22215 | 22204 | } |
| 22216 | 22205 | break; |
| 22217 | 22206 | case OnePossibleValueYes: { |
| 22218 | | ZigValue *pointee = create_const_vals(1); |
| 22219 | | pointee->special = ConstValSpecialStatic; |
| 22220 | | pointee->type = child_type; |
| 22221 | | pointee->parent.id = ConstParentIdOptionalPayload; |
| 22222 | | pointee->parent.data.p_optional_payload.optional_val = optional_val; |
| 22223 | | |
| 22224 | 22207 | optional_val->special = ConstValSpecialStatic; |
| 22225 | | optional_val->data.x_optional = pointee; |
| 22208 | optional_val->data.x_optional = get_the_one_possible_value(ira->codegen, child_type); |
| 22226 | 22209 | break; |
| 22227 | 22210 | } |
| 22228 | 22211 | } |