]> granicus.if.org Git - vim/commitdiff
patch 8.2.2726: confusing error message with white space before comma v8.2.2726
authorBram Moolenaar <Bram@vim.org>
Tue, 6 Apr 2021 17:01:03 +0000 (19:01 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 6 Apr 2021 17:01:03 +0000 (19:01 +0200)
Problem:    Confusing error message with white space before comma in the
            arguments of a function declaration.
Solution:   Give a specific error message. (closes #2235)

src/testdir/test_vim9_func.vim
src/userfunc.c
src/version.c

index 8085e5cf2284857e2ffb3520c243238287340cc7..730cf40aaa50e2b7a7a26856ac3a7fcd25ada402 100644 (file)
@@ -1263,6 +1263,15 @@ def Test_arg_type_wrong()
   CheckScriptFailure(['def Func5(items)', 'echo "a"'], 'E1077:')
 enddef
 
+def Test_white_space_before_comma()
+  var lines =<< trim END
+    vim9script
+    def Func(a: number , b: number)
+    enddef
+  END
+  CheckScriptFailure(lines, 'E1068:')
+enddef
+
 def Test_white_space_after_comma()
   var lines =<< trim END
     vim9script
index 1139573c638a549458b8b600c40f9fcd700d8fb7..af107b0db61c82a8645f2bbaa3093a021c7d5815 100644 (file)
@@ -307,6 +307,17 @@ get_function_args(
                emsg(_("E989: Non-default argument follows default argument"));
                goto err_ret;
            }
+
+           if (VIM_ISWHITE(*p) && *skipwhite(p) == ',')
+           {
+               // Be tolerant when skipping
+               if (!skip)
+               {
+                   semsg(_(e_no_white_space_allowed_before_str_str), ",", p);
+                   goto err_ret;
+               }
+               p = skipwhite(p);
+           }
            if (*p == ',')
            {
                ++p;
index 4318b71eb79634fed0852bbfd6f954813d159b07..9b356bd267692a81ca5d3bbe886fe59501a04db8 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2726,
 /**/
     2725,
 /**/