Functions can currently only return types that support ->dup.
So disallow anything that doesn't.
Signed-off-by: NeilBrown <neil@brown.name>
func test5(a:number):string
print a
+ struct foo
+ a: number
+ b:string = "hello"
+
+ func test6(a:number):foo
+ b:foo
+ b.a = a
+ use b
+
###### output: func_err_args
+ .tmp.code:34:5: error: function cannot return value of type foo
.tmp.code:28:14: error: expected string, found none
.tmp.code:25:8: error: expected string, found number
.tmp.code:15:14: error: insufficient arguments to function.
v->type->function.return_type, 0);
if (!ok)
all_ok = 0;
+ if (!v->type->function.return_type->dup) {
+ type_err(c, "error: function cannot return value of type %1",
+ v->where_decl, v->type->function.return_type, 0, NULL);
+ }
+
v->type->function.local_size = scope_finalize(c);
}
return all_ok;