diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-07-21 20:38:46 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-07-21 20:38:46 +0200 |
commit | c4c5642513ac41b22b7772cc880c776c69e964c9 (patch) | |
tree | 965a03640669df1b17441d048efc895fbe63d18c | |
parent | cd9172077bc8c0aafddf2e5367cc0ae2c00c8ff7 (diff) | |
download | vim-git-8.2.3195.tar.gz |
patch 8.2.3195: Vim9: unclear error when passing too many arguments to lambdav8.2.3195
Problem: Vim9: unclear error when passing too many arguments to lambda.
Solution: Pass the expression itself instead of "[expression]".
(closes #8604)
-rw-r--r-- | src/testdir/test_vim9_func.vim | 6 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9compile.c | 3 |
3 files changed, 9 insertions, 2 deletions
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim index a2c4e7dae..8ac05d421 100644 --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -960,6 +960,12 @@ def Test_call_lambda_args() echo ((a) => a)('aa', 'bb') END 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 def FilterWithCond(x: string, Cond: func(string): bool): bool diff --git a/src/version.c b/src/version.c index 61cd6f7b2..bc26f903d 100644 --- a/src/version.c +++ b/src/version.c @@ -756,6 +756,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3195, +/**/ 3194, /**/ 3193, diff --git a/src/vim9compile.c b/src/vim9compile.c index 701487548..5a39906ef 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -4354,8 +4354,7 @@ compile_subscript( } type = ((type_T **)stack->ga_data)[stack->ga_len - 1]; - if (generate_PCALL(cctx, argcount, - (char_u *)"[expression]", type, FALSE) == FAIL) + if (generate_PCALL(cctx, argcount, p - 2, type, FALSE) == FAIL) return FAIL; } else |