]> granicus.if.org Git - vim/commitdiff
patch 8.2.3195: Vim9: unclear error when passing too many arguments to lambda v8.2.3195
authorBram Moolenaar <Bram@vim.org>
Wed, 21 Jul 2021 18:38:46 +0000 (20:38 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 21 Jul 2021 18:38:46 +0000 (20:38 +0200)
Problem:    Vim9: unclear error when passing too many arguments to lambda.
Solution:   Pass the expression itself instead of "[expression]".
            (closes #8604)

src/testdir/test_vim9_func.vim
src/version.c
src/vim9compile.c

index a2c4e7daed3534d070e8aaca1820e4df0d3ba124..8ac05d421aa7a7541505be0c5171370b3e4462eb 100644 (file)
@@ -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
index 61cd6f7b2f1ed4ae0d285e2072438997be8d64fd..bc26f903df91a8fec52155d25d75cbb18e85588b 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3195,
 /**/
     3194,
 /**/
index 7014875482fadd06053f3f7e26811e51694fe3c1..5a39906efb4dd3825efeb02993ca36feac434a0b 100644 (file)
@@ -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