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
signaturelock-open 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
1866818668 ir_assert(result_loc->value->type->id == ZigTypeIdPointer, suspend_source_instr);
1866918669 ZigType *actual_elem_type = result_loc->value->type->data.pointer.child_type;
1867018670 if (actual_elem_type->id == ZigTypeIdOptional && value_type->id != ZigTypeIdOptional &&
18671 value_type->id != ZigTypeIdNull)
18671 value_type->id != ZigTypeIdNull && value_type->id != ZigTypeIdUndefined)
1867218672 {
1867318673 bool same_comptime_repr = types_have_same_zig_comptime_repr(ira->codegen, actual_elem_type, value_type);
1867418674 if (!same_comptime_repr) {
1867518675 result_loc_pass1->written = was_written;
1867618676 return ir_analyze_unwrap_optional_payload(ira, suspend_source_instr, result_loc, false, true);
1867718677 }
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 {
1867918681 if (value_type->id == ZigTypeIdErrorSet) {
1868018682 return ir_analyze_unwrap_err_code(ira, suspend_source_instr, result_loc, true);
1868118683 } else {
......@@ -18683,7 +18685,7 @@ static IrInstGen *ir_resolve_result(IrAnalyze *ira, IrInst *suspend_source_instr
1868318685 result_loc, false, true);
1868418686 ZigType *actual_payload_type = actual_elem_type->data.error_union.payload_type;
1868518687 if (actual_payload_type->id == ZigTypeIdOptional && value_type->id != ZigTypeIdOptional &&
18686 value_type->id != ZigTypeIdNull)
18688 value_type->id != ZigTypeIdNull && value_type->id != ZigTypeIdUndefined)
1868718689 {
1868818690 return ir_analyze_unwrap_optional_payload(ira, suspend_source_instr, unwrapped_err_ptr, false, true);
1868918691 } else {