aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2020-03-09 22:10:57 -0400
committerGitHub <noreply@github.com>2020-03-09 22:10:57 -0400
commit675f01f1768aa08c307640b53e8a5240fa190fab (patch)
tree14702a748268e301cf5fc23a0d28221c487fae7e /src/ir.cpp
parent1f44b29724b52433d84b43345a52da59f9220e62 (diff)
parente7cc45642138472c29e09cd10e31962426c1aba5 (diff)
downloadzig-675f01f1768aa08c307640b53e8a5240fa190fab.tar.gz
zig-675f01f1768aa08c307640b53e8a5240fa190fab.zip
Merge pull request #4590 from xackus/fix-4587
fix failed assert on generic fn opaque return type
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index e2cf13b77d..e5b28f84c2 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -19392,6 +19392,19 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr,
ZigType *specified_return_type = ir_analyze_type_expr(ira, impl_fn->child_scope, return_type_node);
if (type_is_invalid(specified_return_type))
return ira->codegen->invalid_inst_gen;
+
+ if(!is_valid_return_type(specified_return_type)){
+ ErrorMsg *msg = ir_add_error(ira, source_instr,
+ buf_sprintf("call to generic function with %s return type '%s' not allowed", type_id_name(specified_return_type->id), buf_ptr(&specified_return_type->name)));
+ add_error_note(ira->codegen, msg, fn_proto_node, buf_sprintf("function declared here"));
+
+ Tld *tld = find_decl(ira->codegen, &fn_entry->fndef_scope->base, &specified_return_type->name);
+ if (tld != nullptr) {
+ add_error_note(ira->codegen, msg, tld->source_node, buf_sprintf("type declared here"));
+ }
+ return ira->codegen->invalid_inst_gen;
+ }
+
if (fn_proto_node->data.fn_proto.auto_err_set) {
ZigType *inferred_err_set_type = get_auto_err_set_type(ira->codegen, impl_fn);
if ((err = type_resolve(ira->codegen, specified_return_type, ResolveStatusSizeKnown)))