# HG changeset patch # User Christian Brabandt # Date 1715239806 -7200 # Node ID 920e132817da6c07f2c7bc4bff9e0441db4de0ee # Parent 9ba95f736abbe65f3d6c88c69878c9cde526d5c6 patch 9.1.0400: Vim9: confusing error message for unknown type Commit: https://github.com/vim/vim/commit/1b53172901ebe5be3ddf1baee22d964c8d41e899 Author: Yegappan Lakshmanan Date: Thu May 9 09:12:31 2024 +0200 patch 9.1.0400: Vim9: confusing error message for unknown type Problem: Vim9: confusing error message for unknown type (Doug Kearns) Solution: For an unknown type, display only the type name in the error message (Yegappan Lakshmanan) fixes: #13153 closes: #14736 Signed-off-by: Yegappan Lakshmanan Signed-off-by: Christian Brabandt diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -5002,7 +5002,7 @@ def Test_invalid_type_in_for() enddef defcompile END - v9.CheckSourceFailure(lines, 'E1010: Type not recognized: x in range(10)', 1) + v9.CheckSourceFailure(lines, 'E1010: Type not recognized: x', 1) enddef " Test for using a line break between the variable name and the type in a for @@ -5083,6 +5083,21 @@ def Test_null_values() v9.CheckSourceDefAndScriptSuccess(lines) enddef +" Test for using an unknown type in a typecast +def Test_unknown_type_in_typecast() + var lines =<< trim END + vim9script + var a = b + END + v9.CheckSourceFailure(lines, 'E1010: Type not recognized: MyType', 2) + + lines =<< trim END + vim9script + var Fn = b + END + v9.CheckSourceFailure(lines, 'E1010: Type not recognized: funcx(number, number): number', 2) +enddef + " Keep this last, it messes up highlighting. def Test_substitute_cmd() new diff --git a/src/testdir/test_vim9_typealias.vim b/src/testdir/test_vim9_typealias.vim --- a/src/testdir/test_vim9_typealias.vim +++ b/src/testdir/test_vim9_typealias.vim @@ -363,7 +363,7 @@ def Test_typealias_import() var myNum: A.SomeType = 10 END - v9.CheckScriptFailure(lines, 'E1010: Type not recognized: A.SomeType = 10', 4) + v9.CheckScriptFailure(lines, 'E1010: Type not recognized: A.SomeType', 4) # Use a type alias that is not exported lines =<< trim END diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -705,6 +705,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 400, +/**/ 399, /**/ 398, diff --git a/src/vim9type.c b/src/vim9type.c --- a/src/vim9type.c +++ b/src/vim9type.c @@ -1466,7 +1466,14 @@ parse_type_user_defined( } if (give_error && (did_emsg == did_emsg_before)) + { + char_u *p = skip_type(*arg, FALSE); + char cc = *p; + + *p = NUL; semsg(_(e_type_not_recognized_str), *arg); + *p = cc; + } return NULL; }