checker: include built-in pointer types when checking fn expects non reference. closes #7133

pull/7204/head
joe-conigliaro 2020-12-08 17:11:15 +11:00
parent 44b9ea4a75
commit 8931d3d39c
No known key found for this signature in database
GPG Key ID: C12F7136C08206F1
1 changed files with 2 additions and 1 deletions

View File

@ -1910,7 +1910,8 @@ pub fn (mut c Checker) return_stmt(mut return_stmt ast.Return) {
c.error('cannot use `$got_typ_sym.name` as type `$exp_typ_sym.name` in return argument',
pos)
}
if got_typ.is_ptr() && !exp_type.is_ptr() {
if (got_typ.is_ptr() || got_typ.is_pointer()) &&
(!exp_type.is_ptr() && !exp_type.is_pointer()) {
pos := return_stmt.exprs[i].position()
c.error('fn `$c.cur_fn.name` expects you to return a non reference type `${c.table.type_to_str(exp_type)}`, but you are returning `${c.table.type_to_str(got_typ)}` instead',
pos)