Skip to content

Commit 10e4f12

Browse files
committed
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.
1 parent b816dae commit 10e4f12

4 files changed

Lines changed: 13 additions & 0 deletions

File tree

src/errors.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,4 +268,6 @@ EXTERN char e_cannot_change_dict_item[]
268268
INIT(= N_("E1121: Cannot change dict item"));
269269
EXTERN char e_variable_is_locked_str[]
270270
INIT(= N_("E1122: Variable is locked: %s"));
271+
EXTERN char e_missing_comma_before_argument_str[]
272+
INIT(= N_("E1123: Missing comma before argument: %s"));
271273
#endif

src/testdir/test_vim9_expr.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2112,6 +2112,7 @@ def Test_expr7_call()
21122112
"vim9script",
21132113
"let x = substitute ('x', 'x', 'x', 'x')"
21142114
], 'E121:', 2)
2115+
CheckDefFailure(["let Ref = function('len' [1, 2])"], 'E1123:', 1)
21152116

21162117
let auto_lines =<< trim END
21172118
def g:some#func(): string

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
1719,
753755
/**/
754756
1718,
755757
/**/

src/vim9compile.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2290,6 +2290,7 @@ compile_arguments(char_u **arg, cctx_T *cctx, int *argcount)
22902290
{
22912291
char_u *p = *arg;
22922292
char_u *whitep = *arg;
2293+
int must_end = FALSE;
22932294

22942295
for (;;)
22952296
{
@@ -2300,6 +2301,11 @@ compile_arguments(char_u **arg, cctx_T *cctx, int *argcount)
23002301
*arg = p + 1;
23012302
return OK;
23022303
}
2304+
if (must_end)
2305+
{
2306+
semsg(_(e_missing_comma_before_argument_str), p);
2307+
return FAIL;
2308+
}
23032309

23042310
if (compile_expr0(&p, cctx) == FAIL)
23052311
return FAIL;
@@ -2316,6 +2322,8 @@ compile_arguments(char_u **arg, cctx_T *cctx, int *argcount)
23162322
if (*p != NUL && !VIM_ISWHITE(*p))
23172323
semsg(_(e_white_space_required_after_str), ",");
23182324
}
2325+
else
2326+
must_end = TRUE;
23192327
whitep = p;
23202328
p = skipwhite(p);
23212329
}

0 commit comments

Comments
 (0)