fix regression of storing optional with 0-bit payload

This commit is contained in:
Andrew Kelley
2020-01-28 12:32:39 -05:00
parent 5c55a9b4e8
commit e0000c47bd
2 changed files with 8 additions and 2 deletions

View File

@@ -4731,6 +4731,10 @@ static LLVMValueRef ir_render_optional_unwrap_ptr(CodeGen *g, IrExecutableGen *e
LLVMPositionBuilderAtEnd(g->builder, ok_block);
}
if (!type_has_bits(child_type)) {
if (instruction->initializing) {
LLVMValueRef non_null_bit = LLVMConstInt(LLVMInt1Type(), 1, false);
gen_store_untyped(g, non_null_bit, base_ptr, 0, false);
}
return nullptr;
} else {
bool is_scalar = !handle_is_ptr(maybe_type);