Mercurial > vim
changeset 21763:703ea7603d3e v8.2.1431
patch 8.2.1431: Vim9: no error for white space before comma in dict
Commit: https://github.com/vim/vim/commit/c3d6e8a46a8fc5de622e8df9dbd25edd03e00c5b
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Aug 12 18:34:28 2020 +0200
patch 8.2.1431: Vim9: no error for white space before comma in dict
Problem: Vim9: no error for white space before comma in dict.
Solution: Check for extra white space. (closes https://github.com/vim/vim/issues/6674)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 12 Aug 2020 18:45:06 +0200 |
parents | 75e53f66302e |
children | 476b6faad407 |
files | src/dict.c src/testdir/test_vim9_expr.vim src/version.c src/vim9compile.c |
diffstat | 4 files changed, 20 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/dict.c +++ b/src/dict.c @@ -922,7 +922,12 @@ eval_dict(char_u **arg, typval_T *rettv, if (!had_comma) { if (evaluate) - semsg(_(e_missing_dict_comma), *arg); + { + if (**arg == ',') + semsg(_(e_no_white_before), ","); + else + semsg(_(e_missing_dict_comma), *arg); + } goto failret; } }
--- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -1506,6 +1506,7 @@ def Test_expr7_dict() 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 = #{a: 8 , b: 9}"], 'E1068:') call CheckDefFailure(["let x = #{8: 8}"], 'E1014:') call CheckDefFailure(["let x = #{xxx}"], 'E720:') @@ -1577,6 +1578,12 @@ def Test_expr7_dict_vim9script() let d = #{one:1} END CheckScriptFailure(lines, 'E1069:') + + lines =<< trim END + vim9script + let d = #{one: 1 , two: 2} + END + CheckScriptFailure(lines, 'E1068:') enddef let g:oneString = 'one'
--- a/src/version.c +++ b/src/version.c @@ -755,6 +755,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1431, +/**/ 1430, /**/ 1429,
--- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -2638,6 +2638,11 @@ compile_dict(char_u **arg, cctx_T *cctx, semsg(_(e_missing_dict_comma), *arg); goto failret; } + if (IS_WHITE_OR_NUL(*whitep)) + { + semsg(_(e_no_white_before), ","); + return FAIL; + } whitep = *arg + 1; *arg = skipwhite(*arg + 1); }