diff --git a/src/analyze.cpp b/src/analyze.cpp index 42bf2c8d4f..801852f2cf 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -1510,6 +1510,19 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c } } + if (fn_proto->return_var_token != nullptr) { + if (!calling_convention_allows_zig_types(fn_type_id.cc)) { + add_node_error(g, fn_proto->return_type, + buf_sprintf("return type 'var' not allowed in function with calling convention '%s'", + calling_convention_name(fn_type_id.cc))); + return g->builtin_types.entry_invalid; + } + add_node_error(g, proto_node, + buf_sprintf("TODO implement inferred return types https://github.com/zig-lang/zig/issues/447")); + return g->builtin_types.entry_invalid; + //return get_generic_fn_type(g, &fn_type_id); + } + TypeTableEntry *specified_return_type = analyze_type_expr(g, child_scope, fn_proto->return_type); if (type_is_invalid(specified_return_type)) { fn_type_id.return_type = g->builtin_types.entry_invalid; @@ -1523,16 +1536,6 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c fn_type_id.return_type = specified_return_type; } - if (fn_proto->return_var_token != nullptr) { - if (!calling_convention_allows_zig_types(fn_type_id.cc)) { - add_node_error(g, fn_proto->return_type, - buf_sprintf("return type 'var' not allowed in function with calling convention '%s'", - calling_convention_name(fn_type_id.cc))); - return g->builtin_types.entry_invalid; - } - return get_generic_fn_type(g, &fn_type_id); - } - if (!calling_convention_allows_zig_types(fn_type_id.cc) && !type_allowed_in_extern(g, fn_type_id.return_type)) { add_node_error(g, fn_proto->return_type, buf_sprintf("return type '%s' not allowed in function with calling convention '%s'", diff --git a/src/ir.cpp b/src/ir.cpp index 6fc1322c30..c52ab7388f 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -12019,7 +12019,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal inst_fn_type_id.alignment = align_bytes; } - { + if (fn_proto_node->data.fn_proto.return_var_token == nullptr) { AstNode *return_type_node = fn_proto_node->data.fn_proto.return_type; TypeTableEntry *specified_return_type = analyze_type_expr(ira->codegen, impl_fn->child_scope, return_type_node); if (type_is_invalid(specified_return_type))