# HG changeset patch # User Bram Moolenaar # Date 1640461502 -3600 # Node ID 3aa38eaa5a110fea2f1e9ce48d54ada6e92b2e79 # Parent bf95026c439987985af0735a06456fd95dfd7c8c patch 8.2.3895: Vim9: confusing error when using function() with a number Commit: https://github.com/vim/vim/commit/ae1068afde6dfc6fd3e3f54512dbd089e1559053 Author: Bram Moolenaar Date: Sat Dec 25 19:43:44 2021 +0000 patch 8.2.3895: Vim9: confusing error when using function() with a number Problem: Vim9: confusing error when using function() with a number. Solution: Check for a function or string argument. diff --git a/src/evalfunc.c b/src/evalfunc.c --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -3998,7 +3998,8 @@ common_function(typval_T *argvars, typva 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; diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim --- a/src/testdir/test_vim9_builtin.vim +++ b/src/testdir/test_vim9_builtin.vim @@ -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 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']) diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3895, +/**/ 3894, /**/ 3893,