diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-11-29 18:21:21 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-11-29 18:21:21 -0500 |
| commit | 815b4cfd9d77e5cf3330cc74caf0987f353a8935 (patch) | |
| tree | 2e1b7b0f27df4fcc5b495bd1afc9c131005e3393 /src/ir.cpp | |
| parent | bcdb3a90066148dc5a91d176a8fc7f5d9c7487b1 (diff) | |
| download | zig-815b4cfd9d77e5cf3330cc74caf0987f353a8935.tar.gz zig-815b4cfd9d77e5cf3330cc74caf0987f353a8935.zip | |
fix return result loc as peer result loc in inferred error set function
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 4cedaf95e3..78df2287eb 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -10373,10 +10373,12 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT continue; } ZigType *cur_err_set_type = cur_type->data.error_union.err_set_type; - if (!resolve_inferred_error_set(ira->codegen, cur_err_set_type, cur_inst->source_node)) { + bool allow_infer = cur_err_set_type->data.error_set.infer_fn != nullptr && + cur_err_set_type->data.error_set.infer_fn == ira->new_irb.exec->fn_entry; + if (!allow_infer && !resolve_inferred_error_set(ira->codegen, cur_err_set_type, cur_inst->source_node)) { return ira->codegen->builtin_types.entry_invalid; } - if (type_is_global_error_set(cur_err_set_type)) { + if (!allow_infer && type_is_global_error_set(cur_err_set_type)) { err_set_type = ira->codegen->builtin_types.entry_global_error_set; prev_inst = cur_inst; continue; @@ -16079,6 +16081,10 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe } else { alloca_gen = ir_analyze_alloca(ira, result_loc->source_instruction, value_type, align, alloca_src->name_hint, force_comptime); + if (force_runtime) { + alloca_gen->value->data.x_ptr.mut = ConstPtrMutRuntimeVar; + alloca_gen->value->special = ConstValSpecialRuntime; + } } if (alloca_src->base.child != nullptr && !result_loc->written) { alloca_src->base.child->ref_count = 0; @@ -26993,10 +26999,6 @@ static IrInstruction *ir_analyze_instruction_implicit_cast(IrAnalyze *ira, IrIns if (result_loc != nullptr && (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc))) return result_loc; - if (instruction->result_loc_cast->parent->gen_instruction != nullptr) { - return instruction->result_loc_cast->parent->gen_instruction; - } - ZigType *dest_type = ir_resolve_type(ira, instruction->result_loc_cast->base.source_instruction->child); if (type_is_invalid(dest_type)) return ira->codegen->invalid_instruction; |
