summaryrefslogtreecommitdiffstats
path: root/src/evalfunc.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-07-07 21:21:30 +0200
committerBram Moolenaar <Bram@vim.org>2021-07-07 21:21:30 +0200
commitefc5db5215b4efc424b2de34613525d729a05c93 (patch)
tree8059c2d0768065ca73f17f73d781124bef8cc836 /src/evalfunc.c
parent90df4b9d423485f7db16e3a65cab4f14edc815ae (diff)
patch 8.2.3117: Vim9: type not properly checked in for loopv8.2.3117
Problem: Vim9: type not properly checked in for loop. Solution: Have items() return a list of lists. Add runtime type checks. (closes #8515)
Diffstat (limited to 'src/evalfunc.c')
-rw-r--r--src/evalfunc.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c
index ec74fdeeae..34eac6987c 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -522,6 +522,11 @@ ret_list_dict_any(int argcount UNUSED, type_T **argtypes UNUSED)
return &t_list_dict_any;
}
static type_T *
+ret_list_items(int argcount, type_T **argtypes UNUSED)
+{
+ return &t_list_list_any;
+}
+ static type_T *
ret_dict_any(int argcount UNUSED, type_T **argtypes UNUSED)
{
return &t_dict_any;
@@ -1166,7 +1171,7 @@ static funcentry_T global_functions[] =
{"isnan", 1, 1, FEARG_1, arg1_float_or_nr,
ret_number_bool, MATH_FUNC(f_isnan)},
{"items", 1, 1, FEARG_1, arg1_dict,
- ret_list_any, f_items},
+ ret_list_items, f_items},
{"job_getchannel", 1, 1, FEARG_1, NULL,
ret_channel, JOB_FUNC(f_job_getchannel)},
{"job_info", 0, 1, FEARG_1, NULL,
@@ -3687,6 +3692,7 @@ 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;
}