From 8931d3d39c7dd01ea0b9932c0abb973a71d92bd0 Mon Sep 17 00:00:00 2001 From: joe-conigliaro Date: Tue, 8 Dec 2020 17:11:15 +1100 Subject: [PATCH] checker: include built-in pointer types when checking fn expects non reference. closes #7133 --- vlib/v/checker/checker.v | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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)