1
0
forked from aniani/vim

patch 8.2.3195: Vim9: unclear error when passing too many arguments to lambda

Problem:    Vim9: unclear error when passing too many arguments to lambda.
Solution:   Pass the expression itself instead of "[expression]".
            (closes #8604)
This commit is contained in:
Bram Moolenaar
2021-07-21 20:38:46 +02:00
parent cd9172077b
commit c4c5642513
3 changed files with 9 additions and 2 deletions

View File

@@ -960,6 +960,12 @@ def Test_call_lambda_args()
echo ((a) => a)('aa', 'bb') echo ((a) => a)('aa', 'bb')
END END
CheckDefAndScriptFailure(lines, 'E118:', 1) CheckDefAndScriptFailure(lines, 'E118:', 1)
lines =<< trim END
echo 'aa'->((a) => a)('bb')
END
CheckDefFailure(lines, 'E118: Too many arguments for function: ->((a) => a)(''bb'')', 1)
CheckScriptFailure(['vim9script'] + lines, 'E118: Too many arguments for function: <lambda>', 2)
enddef enddef
def FilterWithCond(x: string, Cond: func(string): bool): bool def FilterWithCond(x: string, Cond: func(string): bool): bool

View File

@@ -755,6 +755,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 */
/**/
3195,
/**/ /**/
3194, 3194,
/**/ /**/

View File

@@ -4354,8 +4354,7 @@ compile_subscript(
} }
type = ((type_T **)stack->ga_data)[stack->ga_len - 1]; type = ((type_T **)stack->ga_data)[stack->ga_len - 1];
if (generate_PCALL(cctx, argcount, if (generate_PCALL(cctx, argcount, p - 2, type, FALSE) == FAIL)
(char_u *)"[expression]", type, FALSE) == FAIL)
return FAIL; return FAIL;
} }
else else