mirror of
https://github.com/vim/vim.git
synced 2025-09-27 04:14:06 -04:00
patch 8.2.1861: Vim9: no specific error when parsing lambda fails
Problem: Vim9: no specific error when parsing lambda fails. Solution: Also give syntax errors when not evaluating. (closes #7154)
This commit is contained in:
@@ -859,14 +859,11 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal)
|
|||||||
if (!vim9script)
|
if (!vim9script)
|
||||||
*arg = skipwhite(*arg);
|
*arg = skipwhite(*arg);
|
||||||
if (**arg != ':')
|
if (**arg != ':')
|
||||||
{
|
|
||||||
if (evaluate)
|
|
||||||
{
|
{
|
||||||
if (*skipwhite(*arg) == ':')
|
if (*skipwhite(*arg) == ':')
|
||||||
semsg(_(e_no_white_space_allowed_before_str), ":");
|
semsg(_(e_no_white_space_allowed_before_str), ":");
|
||||||
else
|
else
|
||||||
semsg(_(e_missing_dict_colon), *arg);
|
semsg(_(e_missing_dict_colon), *arg);
|
||||||
}
|
|
||||||
clear_tv(&tvkey);
|
clear_tv(&tvkey);
|
||||||
goto failret;
|
goto failret;
|
||||||
}
|
}
|
||||||
@@ -899,7 +896,6 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal)
|
|||||||
item = dict_find(d, key, -1);
|
item = dict_find(d, key, -1);
|
||||||
if (item != NULL)
|
if (item != NULL)
|
||||||
{
|
{
|
||||||
if (evaluate)
|
|
||||||
semsg(_(e_duplicate_key), key);
|
semsg(_(e_duplicate_key), key);
|
||||||
clear_tv(&tvkey);
|
clear_tv(&tvkey);
|
||||||
clear_tv(&tv);
|
clear_tv(&tv);
|
||||||
@@ -936,21 +932,17 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal)
|
|||||||
if (**arg == '}')
|
if (**arg == '}')
|
||||||
break;
|
break;
|
||||||
if (!had_comma)
|
if (!had_comma)
|
||||||
{
|
|
||||||
if (evaluate)
|
|
||||||
{
|
{
|
||||||
if (**arg == ',')
|
if (**arg == ',')
|
||||||
semsg(_(e_no_white_space_allowed_before_str), ",");
|
semsg(_(e_no_white_space_allowed_before_str), ",");
|
||||||
else
|
else
|
||||||
semsg(_(e_missing_dict_comma), *arg);
|
semsg(_(e_missing_dict_comma), *arg);
|
||||||
}
|
|
||||||
goto failret;
|
goto failret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (**arg != '}')
|
if (**arg != '}')
|
||||||
{
|
{
|
||||||
if (evaluate)
|
|
||||||
semsg(_(e_missing_dict_end), *arg);
|
semsg(_(e_missing_dict_end), *arg);
|
||||||
failret:
|
failret:
|
||||||
if (d != NULL)
|
if (d != NULL)
|
||||||
|
@@ -1805,6 +1805,13 @@ def Test_expr7_lambda()
|
|||||||
CheckDefExecFailure(["var s = 'asdf'->{a -> a}('x', 'y')"],
|
CheckDefExecFailure(["var s = 'asdf'->{a -> a}('x', 'y')"],
|
||||||
'E1106: 2 arguments too many')
|
'E1106: 2 arguments too many')
|
||||||
CheckDefFailure(["echo 'asdf'->{a -> a}(x)"], 'E1001:', 1)
|
CheckDefFailure(["echo 'asdf'->{a -> a}(x)"], 'E1001:', 1)
|
||||||
|
|
||||||
|
CheckDefSuccess(['var Fx = {a -> #{k1: 0,', ' k2: 1}}'])
|
||||||
|
CheckDefFailure(['var Fx = {a -> #{k1: 0', ' k2: 1}}'], 'E722:', 2)
|
||||||
|
CheckDefFailure(['var Fx = {a -> #{k1: 0,', ' k2 1}}'], 'E720:', 2)
|
||||||
|
|
||||||
|
CheckDefSuccess(['var Fx = {a -> [0,', ' 1]}'])
|
||||||
|
CheckDefFailure(['var Fx = {a -> [0', ' 1]}'], 'E696:', 2)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_expr7_lambda_vim9script()
|
def Test_expr7_lambda_vim9script()
|
||||||
@@ -2371,7 +2378,7 @@ func Test_expr7_fails()
|
|||||||
call CheckDefFailure(["'yes'->", "Echo()"], 'E488: Trailing characters: ->', 1)
|
call CheckDefFailure(["'yes'->", "Echo()"], 'E488: Trailing characters: ->', 1)
|
||||||
|
|
||||||
call CheckDefExecFailure(["[1, 2->len()"], 'E697:', 2)
|
call CheckDefExecFailure(["[1, 2->len()"], 'E697:', 2)
|
||||||
call CheckDefExecFailure(["#{a: 1->len()"], 'E488:', 1)
|
call CheckDefExecFailure(["#{a: 1->len()"], 'E722:', 1)
|
||||||
call CheckDefExecFailure(["{'a': 1->len()"], 'E723:', 2)
|
call CheckDefExecFailure(["{'a': 1->len()"], 'E723:', 2)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
@@ -750,6 +750,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 */
|
||||||
|
/**/
|
||||||
|
1861,
|
||||||
/**/
|
/**/
|
||||||
1860,
|
1860,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user