To: vim_dev@googlegroups.com Subject: Patch 8.2.3895 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3895 Problem: Vim9: confusing error when using function() with a number. Solution: Check for a function or string argument. Files: src/evalfunc.c, src/testdir/test_vim9_builtin.vim *** ../vim-8.2.3894/src/evalfunc.c 2021-12-25 19:29:18.409881900 +0000 --- src/evalfunc.c 2021-12-25 19:33:56.861669477 +0000 *************** *** 3998,4004 **** int is_global = FALSE; if (in_vim9script() ! && (check_for_opt_list_arg(argvars, 1) == FAIL || (argvars[1].v_type != VAR_UNKNOWN && check_for_opt_dict_arg(argvars, 2) == FAIL))) return; --- 3998,4005 ---- int is_global = FALSE; if (in_vim9script() ! && (check_for_string_or_func_arg(argvars, 0) == FAIL ! || check_for_opt_list_arg(argvars, 1) == FAIL || (argvars[1].v_type != VAR_UNKNOWN && check_for_opt_dict_arg(argvars, 2) == FAIL))) return; *** ../vim-8.2.3894/src/testdir/test_vim9_builtin.vim 2021-12-25 19:29:18.409881900 +0000 --- src/testdir/test_vim9_builtin.vim 2021-12-25 19:34:48.417624393 +0000 *************** *** 1352,1357 **** --- 1352,1359 ---- enddef def Test_function() + CheckDefExecAndScriptFailure(['function(123)'], 'E1256: String or function required for argument 1') + CheckDefAndScriptFailure(['function("reverse", 2)'], ['E1013: Argument 2: type mismatch, expected list but got number', 'E1211: List required for argument 2']) CheckDefAndScriptFailure(['function("reverse", [2], [1])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) *** ../vim-8.2.3894/src/version.c 2021-12-25 19:29:18.413881896 +0000 --- src/version.c 2021-12-25 19:35:53.465565549 +0000 *************** *** 751,752 **** --- 751,754 ---- { /* Add new patch number below this line */ + /**/ + 3895, /**/ -- hundred-and-one symptoms of being an internet addict: 105. When someone asks you for your address, you tell them your URL. /// 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 ///