]> granicus.if.org Git - vim/commitdiff
patch 8.2.1719: Vim9: no error if comma is missing in between arguments v8.2.1719
authorBram Moolenaar <Bram@vim.org>
Sun, 20 Sep 2020 20:43:52 +0000 (22:43 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 20 Sep 2020 20:43:52 +0000 (22:43 +0200)
Problem:    Vim9: no error if comma is missing in between arguments.
Solution:   Give an error message.

src/errors.h
src/testdir/test_vim9_expr.vim
src/version.c
src/vim9compile.c

index d12e97f6f37afaf219c7e8324a871e80982612ef..0246fa103a498516e7a1a53395484b5a80d5ee88 100644 (file)
@@ -268,4 +268,6 @@ EXTERN char e_cannot_change_dict_item[]
        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
index b9a68112b58ec9680a431293a52cd23b592c4d2b..411ed7017484ec81960ff2758212101657422bcc 100644 (file)
@@ -2112,6 +2112,7 @@ def Test_expr7_call()
    "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
index 2344ddf2e29476bfe648042667f7add34ca7eb0c..15c497671a45536e9459c33e6709e8d04cad821b 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1719,
 /**/
     1718,
 /**/
index 0db516274aab41533c66b96abc03612feae77c11..1edf48ce6e3a7f751d1c9f12d9c00d84d0c05eaf 100644 (file)
@@ -2290,6 +2290,7 @@ compile_arguments(char_u **arg, cctx_T *cctx, int *argcount)
 {
     char_u  *p = *arg;
     char_u  *whitep = *arg;
+    int            must_end = FALSE;
 
     for (;;)
     {
@@ -2300,6 +2301,11 @@ compile_arguments(char_u **arg, cctx_T *cctx, int *argcount)
            *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 @@ compile_arguments(char_u **arg, cctx_T *cctx, int *argcount)
            if (*p != NUL && !VIM_ISWHITE(*p))
                semsg(_(e_white_space_required_after_str), ",");
        }
+       else
+           must_end = TRUE;
        whitep = p;
        p = skipwhite(p);
     }