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:
@@ -781,7 +781,7 @@ get_literal_key(char_u **arg, typval_T *tv)
|
|||||||
tv->v_type = VAR_STRING;
|
tv->v_type = VAR_STRING;
|
||||||
tv->vval.v_string = vim_strnsave(*arg, p - *arg);
|
tv->vval.v_string = vim_strnsave(*arg, p - *arg);
|
||||||
|
|
||||||
*arg = skipwhite(p);
|
*arg = p;
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -845,7 +845,12 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal)
|
|||||||
if (**arg != ':')
|
if (**arg != ':')
|
||||||
{
|
{
|
||||||
if (evaluate)
|
if (evaluate)
|
||||||
|
{
|
||||||
|
if (*skipwhite(*arg) == ':')
|
||||||
|
semsg(_(e_no_white_before), ":");
|
||||||
|
else
|
||||||
semsg(_(e_missing_dict_colon), *arg);
|
semsg(_(e_missing_dict_colon), *arg);
|
||||||
|
}
|
||||||
clear_tv(&tvkey);
|
clear_tv(&tvkey);
|
||||||
goto failret;
|
goto failret;
|
||||||
}
|
}
|
||||||
|
@@ -1219,7 +1219,12 @@ eval_list(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int do_error)
|
|||||||
if (!had_comma)
|
if (!had_comma)
|
||||||
{
|
{
|
||||||
if (do_error)
|
if (do_error)
|
||||||
|
{
|
||||||
|
if (**arg == ',')
|
||||||
|
semsg(_(e_no_white_before), ",");
|
||||||
|
else
|
||||||
semsg(_("E696: Missing comma in List: %s"), *arg);
|
semsg(_("E696: Missing comma in List: %s"), *arg);
|
||||||
|
}
|
||||||
goto failret;
|
goto failret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1383,7 +1383,10 @@ def Test_expr7_list()
|
|||||||
|
|
||||||
call CheckDefExecFailure(["let x = g:anint[3]"], 'E714:')
|
call CheckDefExecFailure(["let x = g:anint[3]"], 'E714:')
|
||||||
call CheckDefFailure(["let x = g:list_mixed[xxx]"], 'E1001:')
|
call CheckDefFailure(["let x = g:list_mixed[xxx]"], 'E1001:')
|
||||||
|
|
||||||
call CheckDefFailure(["let x = [1,2,3]"], 'E1069:')
|
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 CheckDefExecFailure(["let x = g:list_mixed['xx']"], 'E1029:')
|
||||||
call CheckDefFailure(["let x = g:list_mixed["], 'E1097:')
|
call CheckDefFailure(["let x = g:list_mixed["], 'E1097:')
|
||||||
call CheckDefFailure(["let x = g:list_mixed[0"], 'E1097:')
|
call CheckDefFailure(["let x = g:list_mixed[0"], 'E1097:')
|
||||||
@@ -1422,6 +1425,12 @@ def Test_expr7_list_vim9script()
|
|||||||
let l = [11,22]
|
let l = [11,22]
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E1069:')
|
CheckScriptFailure(lines, 'E1069:')
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
let l = [11 , 22]
|
||||||
|
END
|
||||||
|
CheckScriptFailure(lines, 'E1068:')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_expr7_lambda()
|
def Test_expr7_lambda()
|
||||||
@@ -1556,6 +1565,18 @@ def Test_expr7_dict_vim9script()
|
|||||||
let d = #{one: 1,two: 2}
|
let d = #{one: 1,two: 2}
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E1069:')
|
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
|
enddef
|
||||||
|
|
||||||
let g:oneString = 'one'
|
let g:oneString = 'one'
|
||||||
|
@@ -754,6 +754,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1430,
|
||||||
/**/
|
/**/
|
||||||
1429,
|
1429,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -2394,6 +2394,11 @@ compile_list(char_u **arg, cctx_T *cctx)
|
|||||||
semsg(_(e_list_end), *arg);
|
semsg(_(e_list_end), *arg);
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
if (*p == ',')
|
||||||
|
{
|
||||||
|
semsg(_(e_no_white_before), ",");
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
if (*p == ']')
|
if (*p == ']')
|
||||||
{
|
{
|
||||||
++p;
|
++p;
|
||||||
|
Reference in New Issue
Block a user