]> granicus.if.org Git - vim/commitdiff
patch 8.2.3895: Vim9: confusing error when using function() with a number v8.2.3895
authorBram Moolenaar <Bram@vim.org>
Sat, 25 Dec 2021 19:43:44 +0000 (19:43 +0000)
committerBram Moolenaar <Bram@vim.org>
Sat, 25 Dec 2021 19:43:44 +0000 (19:43 +0000)
Problem:    Vim9: confusing error when using function() with a number.
Solution:   Check for a function or string argument.

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

index e4fa35b4efcf459263e2ad93ed3e814bd08ebfab..9e0fd805d84d1ff048730c0bbee56614f1933c67 100644 (file)
@@ -3998,7 +3998,8 @@ common_function(typval_T *argvars, typval_T *rettv, int is_funcref)
     int                is_global = FALSE;
 
     if (in_vim9script()
-           && (check_for_opt_list_arg(argvars, 1) == FAIL
+           && (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;
index 1bdb12b039c50cbec92341199759223f36079985..547a2132a40490d2dc06277c58505889b0251b8e 100644 (file)
@@ -1352,6 +1352,8 @@ def Test_funcref()
 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<any> but got number', 'E1211: List required for argument 2'])
   CheckDefAndScriptFailure(['function("reverse", [2], [1])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 3'])
 
index c4e4ad081411b65dcf02b02765b167305e148cbb..80d92fc66dc9ae753e7c3957e0bfc9a3b44566f6 100644 (file)
@@ -749,6 +749,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3895,
 /**/
     3894,
 /**/