To: vim_dev@googlegroups.com Subject: Patch 8.2.3148 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3148 Problem: Vim9: function arg type check does not handle base offset. Solution: Take the base offset into account when checking builtin function argument types. Files: src/evalfunc.c, src/vim9compile.c, src/testdir/test_vim9_builtin.vim *** ../vim-8.2.3147/src/evalfunc.c 2021-07-11 14:55:45.253356763 +0200 --- src/evalfunc.c 2021-07-11 18:09:44.147121467 +0200 *************** *** 450,455 **** --- 450,456 ---- 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,1838 **** ret_string, f_visualmode}, {"wildmenumode", 0, 0, 0, NULL, ret_number, f_wildmenumode}, ! {"win_execute", 2, 3, FEARG_2, NULL, ret_string, f_win_execute}, {"win_findbuf", 1, 1, FEARG_1, arg1_number, ret_list_number, f_win_findbuf}, --- 1833,1839 ---- ret_string, f_visualmode}, {"wildmenumode", 0, 0, 0, NULL, ret_number, f_wildmenumode}, ! {"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}, *** ../vim-8.2.3147/src/vim9compile.c 2021-07-11 17:54:55.576891621 +0200 --- src/vim9compile.c 2021-07-11 18:21:38.637660373 +0200 *************** *** 1781,1786 **** --- 1781,1787 ---- 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,1805 **** --- 1801,1816 ---- { // 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; *** ../vim-8.2.3147/src/testdir/test_vim9_builtin.vim 2021-07-11 16:01:54.472064052 +0200 --- src/testdir/test_vim9_builtin.vim 2021-07-11 18:14:09.202559848 +0200 *************** *** 2305,2310 **** --- 2305,2312 ---- 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 *** ../vim-8.2.3147/src/version.c 2021-07-11 17:54:55.580891616 +0200 --- src/version.c 2021-07-11 18:10:51.214975999 +0200 *************** *** 757,758 **** --- 757,760 ---- { /* Add new patch number below this line */ + /**/ + 3148, /**/ -- "A clear conscience is usually the sign of a bad memory." -- Steven Wright /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///