Mercurial > vim
changeset 21556:963913d80284 v8.2.1328
patch 8.2.1328: no space allowed before comma in list
Commit: https://github.com/vim/vim/commit/4d4d1cd5c8b61ef0296bd6190ca2a0b2d6d96ba7
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jul 30 22:14:33 2020 +0200
patch 8.2.1328: no space allowed before comma in list
Problem: No space allowed before comma in list.
Solution: Legacy Vim script allows it. (closes https://github.com/vim/vim/issues/6577)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 30 Jul 2020 22:15:04 +0200 |
parents | 9c4e0f006f67 |
children | 00c9f8522652 |
files | src/dict.c src/list.c src/testdir/test_listdict.vim src/version.c |
diffstat | 4 files changed, 17 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/dict.c +++ b/src/dict.c @@ -838,7 +838,7 @@ eval_dict(char_u **arg, typval_T *rettv, : 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, } 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) {
--- a/src/list.c +++ b/src/list.c @@ -1194,6 +1194,9 @@ eval_list(char_u **arg, typval_T *rettv, 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 == ',';
--- a/src/testdir/test_listdict.vim +++ b/src/testdir/test_listdict.vim @@ -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},}