0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

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 #6668)
            Also check for extra white space in literal dict. (closes #6670)
This commit is contained in:
Bram Moolenaar
2020-08-12 18:01:53 +02:00
parent 17a836cbee
commit db199216e8
5 changed files with 41 additions and 3 deletions

View File

@@ -781,7 +781,7 @@ get_literal_key(char_u **arg, typval_T *tv)
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, evalarg_T *evalarg, int literal)
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;
}

View File

@@ -1219,7 +1219,12 @@ eval_list(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int do_error)
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;
}
}

View File

@@ -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'

View File

@@ -754,6 +754,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1430,
/**/
1429,
/**/

View File

@@ -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;