authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-01-28 13:33:51-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-01-28 13:33:51-05:00
log793d81c4e8b75a8a3d8f51917af6634213b7cabc
tree691073eb072d2fb6cfd2a30e55cb167930d241cb
parent86da9346e4839007931f811fd34498d8209baed0
signature Commit is signed but in an unrecognized format.

fix result locations not handling undefined correctly


1 files changed, 5 insertions(+), 3 deletions(-)

src/ir.cpp+5-3
...@@ -18668,14 +18668,16 @@ static IrInstGen *ir_resolve_result(IrAnalyze *ira, IrInst *suspend_source_instr...@@ -18668,14 +18668,16 @@ static IrInstGen *ir_resolve_result(IrAnalyze *ira, IrInst *suspend_source_instr
18668 ir_assert(result_loc->value->type->id == ZigTypeIdPointer, suspend_source_instr);18668 ir_assert(result_loc->value->type->id == ZigTypeIdPointer, suspend_source_instr);
18669 ZigType *actual_elem_type = result_loc->value->type->data.pointer.child_type;18669 ZigType *actual_elem_type = result_loc->value->type->data.pointer.child_type;
18670 if (actual_elem_type->id == ZigTypeIdOptional && value_type->id != ZigTypeIdOptional &&18670 if (actual_elem_type->id == ZigTypeIdOptional && value_type->id != ZigTypeIdOptional &&
18671 value_type->id != ZigTypeIdNull)18671 value_type->id != ZigTypeIdNull && value_type->id != ZigTypeIdUndefined)
18672 {18672 {
18673 bool same_comptime_repr = types_have_same_zig_comptime_repr(ira->codegen, actual_elem_type, value_type);18673 bool same_comptime_repr = types_have_same_zig_comptime_repr(ira->codegen, actual_elem_type, value_type);
18674 if (!same_comptime_repr) {18674 if (!same_comptime_repr) {
18675 result_loc_pass1->written = was_written;18675 result_loc_pass1->written = was_written;
18676 return ir_analyze_unwrap_optional_payload(ira, suspend_source_instr, result_loc, false, true);18676 return ir_analyze_unwrap_optional_payload(ira, suspend_source_instr, result_loc, false, true);
18677 }18677 }
18678 } else if (actual_elem_type->id == ZigTypeIdErrorUnion && value_type->id != ZigTypeIdErrorUnion) {18678 } else if (actual_elem_type->id == ZigTypeIdErrorUnion && value_type->id != ZigTypeIdErrorUnion &&
18679 value_type->id != ZigTypeIdUndefined)
18680 {
18679 if (value_type->id == ZigTypeIdErrorSet) {18681 if (value_type->id == ZigTypeIdErrorSet) {
18680 return ir_analyze_unwrap_err_code(ira, suspend_source_instr, result_loc, true);18682 return ir_analyze_unwrap_err_code(ira, suspend_source_instr, result_loc, true);
18681 } else {18683 } else {
...@@ -18683,7 +18685,7 @@ static IrInstGen *ir_resolve_result(IrAnalyze *ira, IrInst *suspend_source_instr...@@ -18683,7 +18685,7 @@ static IrInstGen *ir_resolve_result(IrAnalyze *ira, IrInst *suspend_source_instr
18683 result_loc, false, true);18685 result_loc, false, true);
18684 ZigType *actual_payload_type = actual_elem_type->data.error_union.payload_type;18686 ZigType *actual_payload_type = actual_elem_type->data.error_union.payload_type;
18685 if (actual_payload_type->id == ZigTypeIdOptional && value_type->id != ZigTypeIdOptional &&18687 if (actual_payload_type->id == ZigTypeIdOptional && value_type->id != ZigTypeIdOptional &&
18686 value_type->id != ZigTypeIdNull)18688 value_type->id != ZigTypeIdNull && value_type->id != ZigTypeIdUndefined)
18687 {18689 {
18688 return ir_analyze_unwrap_optional_payload(ira, suspend_source_instr, unwrapped_err_ptr, false, true);18690 return ir_analyze_unwrap_optional_payload(ira, suspend_source_instr, unwrapped_err_ptr, false, true);
18689 } else {18691 } else {