authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-29 19:58:00-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-29 19:58:00-05:00
log559bd27b08f6504addd668a1df01b484dd130430
tree25c5b176d7bf4740915ea742159b79ec57b04854
parent815b4cfd9d77e5cf3330cc74caf0987f353a8935
signaturelock-open Commit is signed but in an unrecognized format.

fix `@bitCast` result coercing to error union by returning


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

src/ir.cpp+5-2
......@@ -16314,6 +16314,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe
1631416314 IrInstruction *bitcasted_value;
1631516315 if (value != nullptr) {
1631616316 bitcasted_value = ir_analyze_bit_cast(ira, result_loc->source_instruction, value, dest_type);
16317 dest_type = bitcasted_value->value->type;
1631716318 } else {
1631816319 bitcasted_value = nullptr;
1631916320 }
......@@ -16378,11 +16379,13 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s
1637816379 ir_assert(result_loc->value->type->id == ZigTypeIdPointer, suspend_source_instr);
1637916380 ZigType *actual_elem_type = result_loc->value->type->data.pointer.child_type;
1638016381 if (actual_elem_type->id == ZigTypeIdOptional && value_type->id != ZigTypeIdOptional &&
16381 value_type->id != ZigTypeIdNull && value == nullptr)
16382 value_type->id != ZigTypeIdNull && type_has_bits(value_type))
1638216383 {
1638316384 result_loc_pass1->written = false;
1638416385 return ir_analyze_unwrap_optional_payload(ira, suspend_source_instr, result_loc, false, true);
16385 } else if (actual_elem_type->id == ZigTypeIdErrorUnion && value_type->id != ZigTypeIdErrorUnion && value == nullptr) {
16386 } else if (actual_elem_type->id == ZigTypeIdErrorUnion && value_type->id != ZigTypeIdErrorUnion &&
16387 type_has_bits(value_type))
16388 {
1638616389 if (value_type->id == ZigTypeIdErrorSet) {
1638716390 return ir_analyze_unwrap_err_code(ira, suspend_source_instr, result_loc, true);
1638816391 } else {