diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-12-20 09:36:27 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-12-20 09:36:27 +0000 |
commit | 2f9f4ccfc8f1d4a56761dc1cc1e9e20190a72c74 (patch) | |
tree | cf0a75e97fb4ef537877f7c15d5fc46c6a28e923 /src/evalfunc.c | |
parent | fea43e44c008a7ca73b506ddab0f47b63b5d2126 (diff) |
patch 8.2.3857: Vim9: inconsistent error for using function()v8.2.3857
Problem: Vim9: inconsistent error for using function().
Solution: Use a runtime type check for the result of function().
(closes #8492)
Diffstat (limited to 'src/evalfunc.c')
-rw-r--r-- | src/evalfunc.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c index e670381859..d8c621d54b 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -957,6 +957,11 @@ ret_func_any(int argcount UNUSED, type_T **argtypes UNUSED) return &t_func_any; } static type_T * +ret_func_unknown(int argcount UNUSED, type_T **argtypes UNUSED) +{ + return &t_func_unknown; +} + static type_T * ret_channel(int argcount UNUSED, type_T **argtypes UNUSED) { return &t_channel; @@ -1065,8 +1070,6 @@ ret_maparg(int argcount, type_T **argtypes UNUSED) return &t_string; } -static type_T *ret_f_function(int argcount, type_T **argtypes); - /* * Array with names and number of arguments of all internal functions * MUST BE KEPT SORTED IN strcmp() ORDER FOR BINARY SEARCH! @@ -1429,9 +1432,9 @@ static funcentry_T global_functions[] = {"fullcommand", 1, 1, FEARG_1, arg1_string, ret_string, f_fullcommand}, {"funcref", 1, 3, FEARG_1, arg3_any_list_dict, - ret_func_any, f_funcref}, + ret_func_unknown, f_funcref}, {"function", 1, 3, FEARG_1, arg3_any_list_dict, - ret_f_function, f_function}, + ret_func_unknown, f_function}, {"garbagecollect", 0, 1, 0, arg1_bool, ret_void, f_garbagecollect}, {"get", 2, 3, FEARG_1, arg23_get, @@ -4170,15 +4173,6 @@ f_funcref(typval_T *argvars, typval_T *rettv) common_function(argvars, rettv, TRUE); } - static type_T * -ret_f_function(int argcount, type_T **argtypes) -{ - if (argcount == 1 && argtypes[0]->tt_type == VAR_STRING) - return &t_func_any; - // Need to check the type at runtime, the function may be defined later. - return &t_func_unknown; -} - /* * "function()" function */ |