]> granicus.if.org Git - vim/commitdiff
patch 8.2.2576: Vim9: defining a :func function checks for white space v8.2.2576
authorBram Moolenaar <Bram@vim.org>
Sat, 6 Mar 2021 21:33:12 +0000 (22:33 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 6 Mar 2021 21:33:12 +0000 (22:33 +0100)
Problem:    Vim9: defining a :func function checks for white space after a
            comma in the arguments.
Solution:   Only check for white space in a :def function. (closes #7930)

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

index 2ac8609873dc453cc63387375cd965362dd6e7f2..810b3a3cf013192a4d3b4c36116ad9510fe66014 100644 (file)
@@ -1136,6 +1136,23 @@ def Test_arg_type_wrong()
   CheckScriptFailure(['def Func5(items)', 'echo "a"'], 'E1077:')
 enddef
 
+def Test_white_space_after_comma()
+  var lines =<< trim END
+    vim9script
+    def Func(a: number,b: number)
+    enddef
+  END
+  CheckScriptFailure(lines, 'E1069:')
+
+  # OK in legacy function
+  lines =<< trim END
+    vim9script
+    func Func(a,b)
+    endfunc
+  END
+  CheckScriptSuccess(lines)
+enddef
+
 def Test_vim9script_call()
   var lines =<< trim END
     vim9script
index 04c2641203f6bd4132f4632a5dec518bf3c68474..e89b8858d331549b3bc0430eb50bd96c7c263bdf 100644 (file)
@@ -310,7 +310,8 @@ get_function_args(
                ++p;
                // Don't give this error when skipping, it makes the "->" not
                // found in "{k,v -> x}" and give a confusing error.
-               if (!skip && in_vim9script()
+               // Allow missing space after comma in legacy functions.
+               if (!skip && argtypes != NULL
                                      && !IS_WHITE_OR_NUL(*p) && *p != endchar)
                {
                    semsg(_(e_white_space_required_after_str_str), ",", p - 1);
index 48f3faae15d4e0c8ab0981ee925602c56cef95af..5cbf287705cf82c17b29f32279d3650405d4e1ec 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2576,
 /**/
     2575,
 /**/