patch 8.2.2576: Vim9: defining a :func function checks for white space
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)
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim
index 2ac8609..810b3a3 100644
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -1136,6 +1136,23 @@
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
diff --git a/src/userfunc.c b/src/userfunc.c
index 04c2641..e89b885 100644
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -310,7 +310,8 @@
++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);
diff --git a/src/version.c b/src/version.c
index 48f3faa..5cbf287 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2576,
+/**/
2575,
/**/
2574,