]> granicus.if.org Git - vim/commitdiff
patch 8.2.1429: Vim9: no error for missing white after : in dict v8.2.1429
authorBram Moolenaar <Bram@vim.org>
Wed, 12 Aug 2020 15:35:58 +0000 (17:35 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 12 Aug 2020 15:35:58 +0000 (17:35 +0200)
Problem:    Vim9: no error for missing white after : in dict.
Solution:   Check for white space. (closes #6671)  Also check that there is no
            white before the :.

src/testdir/test_vim9_expr.vim
src/testdir/test_vim9_func.vim
src/version.c
src/vim9compile.c

index 3d16053561068e8e47167a9ff39cac78d6df35c6..a942dd4dea0ccfbb6ea295c562ddd0730ffffd1b 100644 (file)
@@ -1494,6 +1494,10 @@ def Test_expr7_dict()
   mixed = #{a: 234}
   mixed = #{}
 
+  call CheckDefFailure(["let x = #{a:8}"], 'E1069:')
+  call CheckDefFailure(["let x = #{a : 8}"], 'E1068:')
+  call CheckDefFailure(["let x = #{a :8}"], 'E1068:')
+
   call CheckDefFailure(["let x = #{8: 8}"], 'E1014:')
   call CheckDefFailure(["let x = #{xxx}"], 'E720:')
   call CheckDefFailure(["let x = #{xxx: 1", "let y = 2"], 'E722:')
index 24078f56ed9e87ba23115f6415ec7c965bd9c021..1f9768ff9acc6e28f4af44eb35f1966ab64a2db3 100644 (file)
@@ -774,7 +774,7 @@ func Test_InternalFuncRetType()
     enddef
 
     def RetListAny(): list<any>
-      return items({'k' : 'v'})
+      return items({'k': 'v'})
     enddef
 
     def RetListString(): list<string>
index 46d027d14ec6327457674c8dee9226bedcadd6c3..b290fdcb1bbd60ca2edc84c5cdcf120bf8189439 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1429,
 /**/
     1428,
 /**/
index dfcff508fa6db5db3186126688e9bcfce2727d32..502c66f37262369435b01ac1efc5a2ba2bf624d7 100644 (file)
@@ -2593,14 +2593,21 @@ compile_dict(char_u **arg, cctx_T *cctx, int literal)
            }
        }
 
-       *arg = skipwhite(*arg);
        if (**arg != ':')
        {
-           semsg(_(e_missing_dict_colon), *arg);
+           if (*skipwhite(*arg) == ':')
+               semsg(_(e_no_white_before), ":");
+           else
+               semsg(_(e_missing_dict_colon), *arg);
            return FAIL;
        }
-
        whitep = *arg + 1;
+       if (!IS_WHITE_OR_NUL(*whitep))
+       {
+           semsg(_(e_white_after), ":");
+           return FAIL;
+       }
+
        *arg = skipwhite(*arg + 1);
        if (may_get_next_line(whitep, arg, cctx) == FAIL)
        {