]> granicus.if.org Git - vim/commitdiff
patch 8.2.1328: no space allowed before comma in list v8.2.1328
authorBram Moolenaar <Bram@vim.org>
Thu, 30 Jul 2020 20:14:33 +0000 (22:14 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 30 Jul 2020 20:14:33 +0000 (22:14 +0200)
Problem:    No space allowed before comma in list.
Solution:   Legacy Vim script allows it. (closes #6577)

src/dict.c
src/list.c
src/testdir/test_listdict.vim
src/version.c

index 019227f1054efb8a4aa5f306dd2118c38250c2be..af1e1e9c8bfbd6d7bb0044d651e8c19da26445ab 100644 (file)
@@ -838,7 +838,7 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal)
                : eval1(arg, &tvkey, evalarg)) == FAIL) // recursive!
            goto failret;
 
-       // The colon should come right after the key, but this wasn't checked
+       // the colon should come right after the key, but this wasn't checked
        // previously, so only require it in Vim9 script.
        if (!vim9script)
            *arg = skipwhite(*arg);
@@ -895,7 +895,10 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal)
        }
        clear_tv(&tvkey);
 
-       // the comma must come after the value
+       // the comma should come right after the value, but this wasn't checked
+       // previously, so only require it in Vim9 script.
+       if (!vim9script)
+           *arg = skipwhite(*arg);
        had_comma = **arg == ',';
        if (had_comma)
        {
index 5c2f60ef79981a45c2e9b7743667e513d509f3e2..14a31bcfb71b43a37165fccb645541ad608ecbe7 100644 (file)
@@ -1194,6 +1194,9 @@ eval_list(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int do_error)
            else
                clear_tv(&tv);
        }
+       // Legacy Vim script allowed a space before the comma.
+       if (!vim9script)
+           *arg = skipwhite(*arg);
 
        // the comma must come after the value
        had_comma = **arg == ',';
index beeda2f5bb598b5efa2e01a80eeda6e255dccb89..563c79f0d38feadf051b3f2ade07c595b0007395 100644 (file)
@@ -23,6 +23,9 @@ func Test_list_create()
   call assert_equal(10, x)
 endfunc
 
+" This was allowed in legacy Vim script
+let s:list_with_spaces = [1 , 2 , 3]
+
 " List slices
 func Test_list_slice()
   let l = [1, 'as''d', [1, 2, function("strlen")], {'a': 1},]
@@ -202,6 +205,10 @@ func Test_dict()
   call assert_fails("let d={'k' : i}", 'E121:')
 endfunc
 
+" This was allowed in legacy Vim script
+let s:dict_with_spaces = {'one' : 1 , 'two' : 2 , 'three' : 3}
+let s:dict_with_spaces_lit = #{one : 1 , two : 2 , three : 3}
+
 " Dictionary identity
 func Test_dict_identity()
   let d = {001: 'asd', 'b': [1, 2, function('strlen')], -1: {'a': 1},}
index 806e064f5740e336d2fd6fcc347ded69432f4e04..6a939f4c9b24d7f5e9cae87de1ff4e766f977f84 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1328,
 /**/
     1327,
 /**/