diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-11-29 19:58:00 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-11-29 19:58:00 -0500 |
| commit | 559bd27b08f6504addd668a1df01b484dd130430 (patch) | |
| tree | 25c5b176d7bf4740915ea742159b79ec57b04854 | |
| parent | 815b4cfd9d77e5cf3330cc74caf0987f353a8935 (diff) | |
| download | zig-559bd27b08f6504addd668a1df01b484dd130430.tar.gz zig-559bd27b08f6504addd668a1df01b484dd130430.zip | |
fix `@bitCast` result coercing to error union by returning
| -rw-r--r-- | src/ir.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 78df2287eb..e7f75dd567 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -16314,6 +16314,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe IrInstruction *bitcasted_value; if (value != nullptr) { bitcasted_value = ir_analyze_bit_cast(ira, result_loc->source_instruction, value, dest_type); + dest_type = bitcasted_value->value->type; } else { bitcasted_value = nullptr; } @@ -16378,11 +16379,13 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s ir_assert(result_loc->value->type->id == ZigTypeIdPointer, suspend_source_instr); ZigType *actual_elem_type = result_loc->value->type->data.pointer.child_type; if (actual_elem_type->id == ZigTypeIdOptional && value_type->id != ZigTypeIdOptional && - value_type->id != ZigTypeIdNull && value == nullptr) + value_type->id != ZigTypeIdNull && type_has_bits(value_type)) { result_loc_pass1->written = false; return ir_analyze_unwrap_optional_payload(ira, suspend_source_instr, result_loc, false, true); - } else if (actual_elem_type->id == ZigTypeIdErrorUnion && value_type->id != ZigTypeIdErrorUnion && value == nullptr) { + } else if (actual_elem_type->id == ZigTypeIdErrorUnion && value_type->id != ZigTypeIdErrorUnion && + type_has_bits(value_type)) + { if (value_type->id == ZigTypeIdErrorSet) { return ir_analyze_unwrap_err_code(ira, suspend_source_instr, result_loc, true); } else { |
