diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index d99b586967..206138a7ff 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -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)