authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-06-18 15:00:19-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-06-18 15:00:19-04:00
log77e0c53613335a007fb4437c8de99868786313eb
treed188a401abc93135b354fd2971b026ee908f179a
parentf90d17cc4db955ad6a3b866e641bf3bc0e7395f4
signaturelock-open Commit is signed but in an unrecognized format.

fix problem with inferred error set return result


1 files changed, 1 insertions(+), 22 deletions(-)

src/ir.cpp+1-22
......@@ -22469,17 +22469,7 @@ static IrInstruction *ir_analyze_instruction_result_ptr(IrAnalyze *ira, IrInstru
2246922469 if (instruction->result_loc->written && instruction->result_loc->resolved_loc != nullptr &&
2247022470 !instr_is_comptime(result))
2247122471 {
22472 IrInstruction *result_ptr = instruction->result_loc->resolved_loc;
22473 if (result->value.type->id == ZigTypeIdErrorUnion &&
22474 result_ptr->value.type->data.pointer.child_type->id == ZigTypeIdErrorUnion)
22475 {
22476 // Convert the pointer to the result type. They should be the same, except this will resolve
22477 // inferred error sets.
22478 ZigType *new_ptr_type = get_pointer_to_type(ira->codegen, result->value.type, true);
22479 return ir_analyze_ptr_cast(ira, &instruction->base, result_ptr, new_ptr_type, &instruction->base, false);
22480 } else {
22481 return result_ptr;
22482 }
22472 return instruction->result_loc->resolved_loc;
2248322473 }
2248422474 return ir_get_ref(ira, &instruction->base, result, true, false);
2248522475}
......@@ -22506,17 +22496,6 @@ static IrInstruction *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstruct
2250622496 }
2250722497 }
2250822498
22509 ZigType *err_set_type = type_entry->data.error_union.err_set_type;
22510 if (!resolve_inferred_error_set(ira->codegen, err_set_type, instruction->base.source_node)) {
22511 return ira->codegen->invalid_instruction;
22512 }
22513 if (!type_is_global_error_set(err_set_type) &&
22514 err_set_type->data.error_set.err_count == 0)
22515 {
22516 assert(err_set_type->data.error_set.infer_fn == nullptr);
22517 return ir_const_bool(ira, &instruction->base, false);
22518 }
22519
2252022499 return ir_build_test_err_gen(ira, &instruction->base, value);
2252122500 } else if (type_entry->id == ZigTypeIdErrorSet) {
2252222501 return ir_const_bool(ira, &instruction->base, true);