# HG changeset patch # User Bram Moolenaar # Date 1597248904 -7200 # Node ID 5a2373c25a86a5684236258fb97f46d30ffd6431 # Parent 5abc63ecc7a4568e28823a9ea541e15f710bdd48 patch 8.2.1430: Vim9: error for missing comma instead of extra white space Commit: https://github.com/vim/vim/commit/db199216e81865350a8d56a603bb86cab672bfad Author: Bram Moolenaar Date: Wed Aug 12 18:01:53 2020 +0200 patch 8.2.1430: Vim9: error for missing comma instead of extra white space Problem: Vim9: error for missing comma instead of extra white space. Solution: Check if comma can be found after white space. (closes https://github.com/vim/vim/issues/6668) Also check for extra white space in literal dict. (closes #6670) diff --git a/src/dict.c b/src/dict.c --- a/src/dict.c +++ b/src/dict.c @@ -781,7 +781,7 @@ get_literal_key(char_u **arg, typval_T * 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, 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; } diff --git a/src/list.c b/src/list.c --- a/src/list.c +++ b/src/list.c @@ -1219,7 +1219,12 @@ eval_list(char_u **arg, typval_T *rettv, 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; } } diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim --- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -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' diff --git a/src/version.c b/src/version.c --- 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 */ /**/ + 1430, +/**/ 1429, /**/ 1428, diff --git a/src/vim9compile.c b/src/vim9compile.c --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -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;