]> granicus.if.org Git - vim/commitdiff
patch 8.2.1430: Vim9: error for missing comma instead of extra white space v8.2.1430
authorBram Moolenaar <Bram@vim.org>
Wed, 12 Aug 2020 16:01:53 +0000 (18:01 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 12 Aug 2020 16:01:53 +0000 (18:01 +0200)
Problem:    Vim9: error for missing comma instead of extra white space.
Solution:   Check if comma can be found after white space. (closes #6668)
            Also check for extra white space in literal dict. (closes #6670)

src/dict.c
src/list.c
src/testdir/test_vim9_expr.vim
src/version.c
src/vim9compile.c

index b381d476dc80ed0dcbe3f2e3b9d28c684cc63b59..b6c9016342d2209d9b4b1b5c6c3b32560950e732 100644 (file)
@@ -781,7 +781,7 @@ get_literal_key(char_u **arg, typval_T *tv)
     tv->v_type = VAR_STRING;
     tv->vval.v_string = vim_strnsave(*arg, p - *arg);
 
-    *arg = skipwhite(p);
+    *arg = p;
     return OK;
 }
 
@@ -845,7 +845,12 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal)
        if (**arg != ':')
        {
            if (evaluate)
-               semsg(_(e_missing_dict_colon), *arg);
+           {
+               if (*skipwhite(*arg) == ':')
+                   semsg(_(e_no_white_before), ":");
+               else
+                   semsg(_(e_missing_dict_colon), *arg);
+           }
            clear_tv(&tvkey);
            goto failret;
        }
index 14a31bcfb71b43a37165fccb645541ad608ecbe7..212d8272adc616abd0f5bc7f722cc23a23c416ea 100644 (file)
@@ -1219,7 +1219,12 @@ eval_list(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int do_error)
        if (!had_comma)
        {
            if (do_error)
-               semsg(_("E696: Missing comma in List: %s"), *arg);
+           {
+               if (**arg == ',')
+                   semsg(_(e_no_white_before), ",");
+               else
+                   semsg(_("E696: Missing comma in List: %s"), *arg);
+           }
            goto failret;
        }
     }
index a942dd4dea0ccfbb6ea295c562ddd0730ffffd1b..e963d9471ddfececc21cbd28e54cea3a42d76cb9 100644 (file)
@@ -1383,7 +1383,10 @@ def Test_expr7_list()
 
   call CheckDefExecFailure(["let x = g:anint[3]"], 'E714:')
   call CheckDefFailure(["let x = g:list_mixed[xxx]"], 'E1001:')
+
   call CheckDefFailure(["let x = [1,2,3]"], 'E1069:')
+  call CheckDefFailure(["let x = [1 ,2, 3]"], 'E1068:')
+
   call CheckDefExecFailure(["let x = g:list_mixed['xx']"], 'E1029:')
   call CheckDefFailure(["let x = g:list_mixed["], 'E1097:')
   call CheckDefFailure(["let x = g:list_mixed[0"], 'E1097:')
@@ -1422,6 +1425,12 @@ def Test_expr7_list_vim9script()
       let l = [11,22]
   END
   CheckScriptFailure(lines, 'E1069:')
+
+  lines =<< trim END
+      vim9script
+      let l = [11 , 22]
+  END
+  CheckScriptFailure(lines, 'E1068:')
 enddef
 
 def Test_expr7_lambda()
@@ -1556,6 +1565,18 @@ def Test_expr7_dict_vim9script()
       let d = #{one: 1,two: 2}
   END
   CheckScriptFailure(lines, 'E1069:')
+
+  lines =<< trim END
+      vim9script
+      let d = #{one : 1}
+  END
+  CheckScriptFailure(lines, 'E1068:')
+
+  lines =<< trim END
+      vim9script
+      let d = #{one:1}
+  END
+  CheckScriptFailure(lines, 'E1069:')
 enddef
 
 let g:oneString = 'one'
index b290fdcb1bbd60ca2edc84c5cdcf120bf8189439..7bafa94330cf26f6102e07c8cb04e1907929ad80 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1430,
 /**/
     1429,
 /**/
index 502c66f37262369435b01ac1efc5a2ba2bf624d7..6c43ad2f919385a171c45b54de0d3f5eacf0b50a 100644 (file)
@@ -2394,6 +2394,11 @@ compile_list(char_u **arg, cctx_T *cctx)
            semsg(_(e_list_end), *arg);
            return FAIL;
        }
+       if (*p == ',')
+       {
+           semsg(_(e_no_white_before), ",");
+           return FAIL;
+       }
        if (*p == ']')
        {
            ++p;