aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-06-11 13:27:01 -0400
committerAndrew Kelley <andrew@ziglang.org>2019-06-11 13:27:01 -0400
commitfc8d8812404e79716e15fd301058032485e8bb64 (patch)
tree5e868ca349bb395525d727fa6347eee58a24f5a2 /src/codegen.cpp
parent06f307ff77adac0451b10643a033714c1d309010 (diff)
downloadzig-fc8d8812404e79716e15fd301058032485e8bb64.tar.gz
zig-fc8d8812404e79716e15fd301058032485e8bb64.zip
fix struct and array init when result casted to anyerror!?T
Diffstat (limited to 'src/codegen.cpp')
-rw-r--r--src/codegen.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp
index 2d1ea07bf3..a040d377cf 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -4908,7 +4908,7 @@ static LLVMValueRef ir_render_unwrap_err_code(CodeGen *g, IrExecutable *executab
static LLVMValueRef ir_render_unwrap_err_payload(CodeGen *g, IrExecutable *executable,
IrInstructionUnwrapErrPayload *instruction)
{
- bool want_safety = ir_want_runtime_safety(g, &instruction->base) && instruction->safety_check_on &&
+ bool want_safety = instruction->safety_check_on && ir_want_runtime_safety(g, &instruction->base) &&
g->errors_by_index.length > 1;
if (!want_safety && !type_has_bits(instruction->base.value.type))
return nullptr;
@@ -4944,6 +4944,11 @@ static LLVMValueRef ir_render_unwrap_err_payload(CodeGen *g, IrExecutable *execu
}
if (type_has_bits(payload_type)) {
+ if (instruction->initializing) {
+ LLVMValueRef err_tag_ptr = LLVMBuildStructGEP(g->builder, err_union_handle, err_union_err_index, "");
+ LLVMValueRef ok_err_val = LLVMConstNull(get_llvm_type(g, g->err_tag_type));
+ gen_store_untyped(g, ok_err_val, err_tag_ptr, 0, false);
+ }
return LLVMBuildStructGEP(g->builder, err_union_handle, err_union_payload_index, "");
} else {
return nullptr;