mirror of
https://github.com/vim/vim.git
synced 2025-10-03 05:14:07 -04:00
patch 9.0.0553: no error for "|" after "{" in lamda
Problem: No error for "|" after "{" in lamda. Solution: Check for invalid "|". (closes #11199)
This commit is contained in:
@@ -1492,6 +1492,29 @@ def Test_lambda_uses_assigned_var()
|
||||
'x = filter(["bbb"], (_, v) => v =~ x)'])
|
||||
enddef
|
||||
|
||||
def Test_lambda_invalid_block()
|
||||
var lines =<< trim END
|
||||
timer_start(0, (_) => { # echo
|
||||
echo 'yes'
|
||||
})
|
||||
END
|
||||
v9.CheckDefAndScriptSuccess(lines)
|
||||
|
||||
lines =<< trim END
|
||||
timer_start(0, (_) => { " echo
|
||||
echo 'yes'
|
||||
})
|
||||
END
|
||||
v9.CheckDefAndScriptFailure(lines, 'E488: Trailing characters: " echo')
|
||||
|
||||
lines =<< trim END
|
||||
timer_start(0, (_) => { | echo
|
||||
echo 'yes'
|
||||
})
|
||||
END
|
||||
v9.CheckDefAndScriptFailure(lines, 'E488: Trailing characters: | echo')
|
||||
enddef
|
||||
|
||||
def Test_pass_legacy_lambda_to_def_func()
|
||||
var lines =<< trim END
|
||||
vim9script
|
||||
|
@@ -1166,6 +1166,7 @@ lambda_function_body(
|
||||
garray_T *default_args,
|
||||
char_u *ret_type)
|
||||
{
|
||||
char_u *start = *arg;
|
||||
int evaluate = (evalarg->eval_flags & EVAL_EVALUATE);
|
||||
garray_T *gap = &evalarg->eval_ga;
|
||||
garray_T *freegap = &evalarg->eval_freega;
|
||||
@@ -1179,9 +1180,10 @@ lambda_function_body(
|
||||
int lnum_save = -1;
|
||||
linenr_T sourcing_lnum_top = SOURCING_LNUM;
|
||||
|
||||
if (!ends_excmd2(*arg, skipwhite(*arg + 1)))
|
||||
*arg = skipwhite(*arg + 1);
|
||||
if (**arg == '|' || !ends_excmd2(start, *arg))
|
||||
{
|
||||
semsg(_(e_trailing_characters_str), *arg + 1);
|
||||
semsg(_(e_trailing_characters_str), *arg);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
|
@@ -699,6 +699,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
553,
|
||||
/**/
|
||||
552,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user