diff --git a/vlib/v/parser/fn.v b/vlib/v/parser/fn.v index 9b43ca7751..acee18244b 100644 --- a/vlib/v/parser/fn.v +++ b/vlib/v/parser/fn.v @@ -503,7 +503,7 @@ run them via `v file.v` instead', && elem_type_sym.language == .v } if is_non_local { - p.error_with_pos('cannot define new methods on non-local type ${type_sym.name}', + p.error_with_pos('cannot define new methods on non-local type ${type_sym.name}. Define an alias and use that instead like `type AliasName = ${type_sym.name}` ', rec.type_pos) return ast.FnDecl{ scope: unsafe { nil } diff --git a/vlib/v/parser/tests/method_decl_on_non_local_array.out b/vlib/v/parser/tests/method_decl_on_non_local_array.out index f01fc00045..4d82b0f325 100644 --- a/vlib/v/parser/tests/method_decl_on_non_local_array.out +++ b/vlib/v/parser/tests/method_decl_on_non_local_array.out @@ -1,4 +1,4 @@ -vlib/v/parser/tests/method_decl_on_non_local_array.vv:1:7: error: cannot define new methods on non-local type []int +vlib/v/parser/tests/method_decl_on_non_local_array.vv:1:7: error: cannot define new methods on non-local type []int. Define an alias and use that instead like `type AliasName = []int` 1 | fn (a []int) get_number() int { | ~~~~~ 2 | return 1 diff --git a/vlib/v/parser/tests/method_decl_on_non_local_map.out b/vlib/v/parser/tests/method_decl_on_non_local_map.out index d8459da3a3..015d530977 100644 --- a/vlib/v/parser/tests/method_decl_on_non_local_map.out +++ b/vlib/v/parser/tests/method_decl_on_non_local_map.out @@ -1,4 +1,4 @@ -vlib/v/parser/tests/method_decl_on_non_local_map.vv:1:7: error: cannot define new methods on non-local type map[string]string +vlib/v/parser/tests/method_decl_on_non_local_map.vv:1:7: error: cannot define new methods on non-local type map[string]string. Define an alias and use that instead like `type AliasName = map[string]string` 1 | fn (a map[string]string) get_number() int { | ~~~~~~~~~~~~~~~~~ 2 | return 1 diff --git a/vlib/v/parser/tests/method_decl_on_non_local_type.out b/vlib/v/parser/tests/method_decl_on_non_local_type.out index 1b57bbd2b0..90dc2b7dd9 100644 --- a/vlib/v/parser/tests/method_decl_on_non_local_type.out +++ b/vlib/v/parser/tests/method_decl_on_non_local_type.out @@ -1,4 +1,4 @@ -vlib/v/parser/tests/method_decl_on_non_local_type.vv:1:7: error: cannot define new methods on non-local type int +vlib/v/parser/tests/method_decl_on_non_local_type.vv:1:7: error: cannot define new methods on non-local type int. Define an alias and use that instead like `type AliasName = int` 1 | fn (a int) get_number() int { | ~~~ 2 | return 1