]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0400: Vim9: confusing error message for unknown type v9.1.0400
authorYegappan Lakshmanan <yegappan@yahoo.com>
Thu, 9 May 2024 07:12:31 +0000 (09:12 +0200)
committerChristian Brabandt <cb@256bit.org>
Thu, 9 May 2024 07:15:02 +0000 (09:15 +0200)
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 <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/testdir/test_vim9_script.vim
src/testdir/test_vim9_typealias.vim
src/version.c
src/vim9type.c

index 3ac106eaaff7985e100bdf0c90766209f5446d67..2c3c47f0a923383f3193995203af1e54763f8095 100644 (file)
@@ -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 = <MyType>b
+  END
+  v9.CheckSourceFailure(lines, 'E1010: Type not recognized: MyType', 2)
+
+  lines =<< trim END
+    vim9script
+    var Fn = <funcx(number, number): number>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
index cf540c2306594ebf9307c29826d43471a34b683d..2792d45dc93dceed399d24437f638af712f03f03 100644 (file)
@@ -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
index 06f0c627601ff5f7dc0dddf2df0a314c741b9a2c..db95d7b56881021869abe1669a602e167432a7e3 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    400,
 /**/
     399,
 /**/
index 517dee2805fb012896e5fc11867b02f029535556..ffdf7facb946900d24a0c92a5ea1450f38c78464 100644 (file)
@@ -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;
 }