]> granicus.if.org Git - vim/commitdiff
patch 8.2.2741: Vim9: Partial call does not check right arguments v8.2.2741
authorBram Moolenaar <Bram@vim.org>
Fri, 9 Apr 2021 20:12:44 +0000 (22:12 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 9 Apr 2021 20:12:44 +0000 (22:12 +0200)
Problem:    Vim9: Partial call does not check right arguments.
Solution:   Adjust the offset for whether the partial is before or after the
            arguments. (closes #8091)

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

index d48cab452e76102cfb771a0c231cf90a5e38ebb6..85830a36ced442672588c15e6ba45326a392ea92 100644 (file)
@@ -796,6 +796,8 @@ def Test_call_lambda_args()
     assert_equal('anything', Callback())
     assert_equal('anything', Callback(1))
     assert_equal('anything', Callback('a', 2))
+
+    assert_equal('xyz', ((a: string): string => a)('xyz'))
   END
   CheckDefAndScriptSuccess(lines)
 
index 74a0ae6e7f221b7e0bd18f19525bde74a544eb3e..64c5af40b2f495877dd96c28e843774746d24fcf 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2741,
 /**/
     2740,
 /**/
index 2cfc12798da7b9e298cbed59a4e5bca971052fdd..c2735dcbd4724903200bd8fb1041f6b97c921318 100644 (file)
@@ -1969,7 +1969,7 @@ generate_PCALL(
 
                for (i = 0; i < argcount; ++i)
                {
-                   int     offset = -argcount + i - 1;
+                   int     offset = -argcount + i - (at_top ? 0 : 1);
                    type_T *actual = ((type_T **)stack->ga_data)[
                                                       stack->ga_len + offset];
                    type_T *expected;