]> granicus.if.org Git - vim/commitdiff
patch 8.2.3148: Vim9: function arg type check does not handle base offset v8.2.3148
authorBram Moolenaar <Bram@vim.org>
Sun, 11 Jul 2021 16:23:19 +0000 (18:23 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 11 Jul 2021 16:23:19 +0000 (18:23 +0200)
Problem:    Vim9: function arg type check does not handle base offset.
Solution:   Take the base offset into account when checking builtin function
            argument types.

src/evalfunc.c
src/testdir/test_vim9_builtin.vim
src/version.c
src/vim9compile.c

index 73012d45d6e41f7bd3918b2c327f9c6777cd91de..3041a6c3805d4280b473cd2ac2943c58792a12ad 100644 (file)
@@ -450,6 +450,7 @@ argcheck_T arg2_dict_string_or_nr[] = {arg_dict_any, arg_string_or_nr};
 argcheck_T arg2_string_dict[] = {arg_string, arg_dict_any};
 argcheck_T arg2_listblob_item[] = {arg_list_or_blob, arg_item_of_prev};
 argcheck_T arg2_execute[] = {arg_string_or_list, arg_string};
+argcheck_T arg23_win_execute[] = {arg_number, arg_string_or_list, arg_string};
 argcheck_T arg23_extend[] = {arg_list_or_dict, arg_same_as_prev, arg_extend3};
 argcheck_T arg23_extendnew[] = {arg_list_or_dict, arg_same_struct_as_prev, arg_extend3};
 argcheck_T arg3_string[] = {arg_string, arg_string, arg_string};
@@ -1832,7 +1833,7 @@ static funcentry_T global_functions[] =
                        ret_string,         f_visualmode},
     {"wildmenumode",   0, 0, 0,            NULL,
                        ret_number,         f_wildmenumode},
-    {"win_execute",    2, 3, FEARG_2,      NULL,
+    {"win_execute",    2, 3, FEARG_2,      arg23_win_execute,
                        ret_string,         f_win_execute},
     {"win_findbuf",    1, 1, FEARG_1,      arg1_number,
                        ret_list_number,    f_win_findbuf},
index e26c2c0dd14b106f443ece940d2ad1d6b8353593..a17d92a19a4f086e2c74f1a754e41616dab526a0 100644 (file)
@@ -2305,6 +2305,8 @@ enddef
 
 def Test_win_execute()
   assert_equal("\n" .. winnr(), win_execute(win_getid(), 'echo winnr()'))
+  assert_equal("\n" .. winnr(), 'echo winnr()'->win_execute(win_getid()))
+  assert_equal("\n" .. winnr(), win_execute(win_getid(), 'echo winnr()', 'silent'))
   assert_equal('', win_execute(342343, 'echo winnr()'))
 enddef
 
index 993d1631855d8e653035b39813d3cb1f3f69a61e..10e01ac86b42f4dd9c4ea8bf21e4067353869171 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3148,
 /**/
     3147,
 /**/
index b04e750ef564e8172ec32d31ab8e00f3611477c8..15c8ef6a8c254ba22836d9f31a52febb9479469d 100644 (file)
@@ -1781,6 +1781,7 @@ generate_BCALL(cctx_T *cctx, int func_idx, int argcount, int method_call)
     garray_T   *stack = &cctx->ctx_type_stack;
     int                argoff;
     type_T     **argtypes = NULL;
+    type_T     *shuffled_argtypes[MAX_FUNC_ARGS];
     type_T     *maptype = NULL;
 
     RETURN_OK_IF_SKIP(cctx);
@@ -1800,6 +1801,16 @@ generate_BCALL(cctx_T *cctx, int func_idx, int argcount, int method_call)
     {
        // Check the types of the arguments.
        argtypes = ((type_T **)stack->ga_data) + stack->ga_len - argcount;
+       if (method_call && argoff > 1)
+       {
+           int i;
+
+           for (i = 0; i < argcount; ++i)
+               shuffled_argtypes[i] = (i < argoff - 1)
+                           ? argtypes[i + 1]
+                           : (i == argoff - 1) ? argtypes[0] : argtypes[i];
+           argtypes = shuffled_argtypes;
+       }
        if (internal_func_check_arg_types(argtypes, func_idx, argcount,
                                                                 cctx) == FAIL)
            return FAIL;