patch 8.2.1719: Vim9: no error if comma is missing in between arguments
Problem: Vim9: no error if comma is missing in between arguments.
Solution: Give an error message.
diff --git a/src/errors.h b/src/errors.h
index d12e97f..0246fa1 100644
--- a/src/errors.h
+++ b/src/errors.h
@@ -268,4 +268,6 @@
INIT(= N_("E1121: Cannot change dict item"));
EXTERN char e_variable_is_locked_str[]
INIT(= N_("E1122: Variable is locked: %s"));
+EXTERN char e_missing_comma_before_argument_str[]
+ INIT(= N_("E1123: Missing comma before argument: %s"));
#endif
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim
index b9a6811..411ed70 100644
--- a/src/testdir/test_vim9_expr.vim
+++ b/src/testdir/test_vim9_expr.vim
@@ -2112,6 +2112,7 @@
"vim9script",
"let x = substitute ('x', 'x', 'x', 'x')"
], 'E121:', 2)
+ CheckDefFailure(["let Ref = function('len' [1, 2])"], 'E1123:', 1)
let auto_lines =<< trim END
def g:some#func(): string
diff --git a/src/version.c b/src/version.c
index 2344ddf..15c4976 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1719,
+/**/
1718,
/**/
1717,
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 0db5162..1edf48c 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -2290,6 +2290,7 @@
{
char_u *p = *arg;
char_u *whitep = *arg;
+ int must_end = FALSE;
for (;;)
{
@@ -2300,6 +2301,11 @@
*arg = p + 1;
return OK;
}
+ if (must_end)
+ {
+ semsg(_(e_missing_comma_before_argument_str), p);
+ return FAIL;
+ }
if (compile_expr0(&p, cctx) == FAIL)
return FAIL;
@@ -2316,6 +2322,8 @@
if (*p != NUL && !VIM_ISWHITE(*p))
semsg(_(e_white_space_required_after_str), ",");
}
+ else
+ must_end = TRUE;
whitep = p;
p = skipwhite(p);
}