| ... | ... | @@ -34,6 +34,7 @@ struct IrAnalyze { |
| 34 | 34 | size_t old_bb_index; |
| 35 | 35 | size_t instruction_index; |
| 36 | 36 | ZigType *explicit_return_type; |
| 37 | AstNode *explicit_return_type_source_node; |
| 37 | 38 | ZigList<IrInstruction *> src_implicit_return_type_list; |
| 38 | 39 | IrBasicBlock *const_predecessor_bb; |
| 39 | 40 | }; |
| ... | ... | @@ -11162,8 +11163,12 @@ static IrInstruction *ir_analyze_instruction_return(IrAnalyze *ira, IrInstructio |
| 11162 | 11163 | return ir_unreach_error(ira); |
| 11163 | 11164 | |
| 11164 | 11165 | IrInstruction *casted_value = ir_implicit_cast(ira, value, ira->explicit_return_type); |
| 11165 | | if (type_is_invalid(casted_value->value.type)) |
| 11166 | if (type_is_invalid(casted_value->value.type) && ira->explicit_return_type_source_node != nullptr) { |
| 11167 | ErrorMsg *msg = ira->codegen->errors.last(); |
| 11168 | add_error_note(ira->codegen, msg, ira->explicit_return_type_source_node, |
| 11169 | buf_sprintf("return type declared here")); |
| 11166 | 11170 | return ir_unreach_error(ira); |
| 11171 | } |
| 11167 | 11172 | |
| 11168 | 11173 | if (casted_value->value.special == ConstValSpecialRuntime && |
| 11169 | 11174 | casted_value->value.type->id == ZigTypeIdPointer && |
| ... | ... | @@ -21213,6 +21218,7 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ |
| 21213 | 21218 | ZigFn *fn_entry = exec_fn_entry(old_exec); |
| 21214 | 21219 | bool is_async = fn_entry != nullptr && fn_entry->type_entry->data.fn.fn_type_id.cc == CallingConventionAsync; |
| 21215 | 21220 | ira->explicit_return_type = is_async ? get_promise_type(codegen, expected_type) : expected_type; |
| 21221 | ira->explicit_return_type_source_node = expected_type_source_node; |
| 21216 | 21222 | |
| 21217 | 21223 | ira->old_irb.codegen = codegen; |
| 21218 | 21224 | ira->old_irb.exec = old_exec; |