Commit 6b5cfd9d99
Changed files (2)
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'",
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))