mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.1454: Vim9: failure invoking lambda with wrong arguments
Problem: Vim9: failure invoking lambda with wrong arguments. Solution: Handle invalid arguments. Add a test.
This commit is contained in:
@@ -1584,6 +1584,14 @@ def Test_expr7_lambda()
|
|||||||
|
|
||||||
call CheckDefFailure(["filter([1, 2], {k,v -> 1})"], 'E1069:')
|
call CheckDefFailure(["filter([1, 2], {k,v -> 1})"], 'E1069:')
|
||||||
call CheckDefFailure(["let L = {a -> a + b}"], 'E1001:')
|
call CheckDefFailure(["let L = {a -> a + b}"], 'E1001:')
|
||||||
|
|
||||||
|
assert_equal('xxxyyy', 'xxx'->{a, b -> a .. b}('yyy'))
|
||||||
|
|
||||||
|
CheckDefExecFailure(["let s = 'asdf'->{a -> a}('x')"],
|
||||||
|
'E1106: one argument too many')
|
||||||
|
CheckDefExecFailure(["let s = 'asdf'->{a -> a}('x', 'y')"],
|
||||||
|
'E1106: 2 arguments too many')
|
||||||
|
CheckDefFailure(["echo 'asdf'->{a -> a}(x)"], 'E1001:')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_expr7_lambda_vim9script()
|
def Test_expr7_lambda_vim9script()
|
||||||
|
@@ -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 */
|
||||||
|
/**/
|
||||||
|
1454,
|
||||||
/**/
|
/**/
|
||||||
1453,
|
1453,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -1361,6 +1361,9 @@ generate_CALL(cctx_T *cctx, ufunc_T *ufunc, int pushed_argcount)
|
|||||||
continue;
|
continue;
|
||||||
expected = ufunc->uf_arg_types[i];
|
expected = ufunc->uf_arg_types[i];
|
||||||
}
|
}
|
||||||
|
else if (ufunc->uf_va_type == NULL)
|
||||||
|
// possibly a lambda
|
||||||
|
expected = &t_any;
|
||||||
else
|
else
|
||||||
expected = ufunc->uf_va_type->tt_member;
|
expected = ufunc->uf_va_type->tt_member;
|
||||||
actual = ((type_T **)stack->ga_data)[stack->ga_len - argcount + i];
|
actual = ((type_T **)stack->ga_data)[stack->ga_len - argcount + i];
|
||||||
|
@@ -206,7 +206,10 @@ call_dfunc(int cdf_idx, int argcount_arg, ectx_T *ectx)
|
|||||||
arg_to_add = ufunc->uf_args.ga_len - argcount;
|
arg_to_add = ufunc->uf_args.ga_len - argcount;
|
||||||
if (arg_to_add < 0)
|
if (arg_to_add < 0)
|
||||||
{
|
{
|
||||||
iemsg("Argument count wrong?");
|
if (arg_to_add == -1)
|
||||||
|
emsg(_("E1106: one argument too many"));
|
||||||
|
else
|
||||||
|
semsg(_("E1106: %d arguments too many"), -arg_to_add);
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
if (ga_grow(&ectx->ec_stack, arg_to_add + 3
|
if (ga_grow(&ectx->ec_stack, arg_to_add + 3
|
||||||
|
Reference in New Issue
Block a user