diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-08-30 17:45:33 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-08-30 17:45:33 +0100 |
commit | 3e518a8ec74065aedd67d352c93d6ae6be550316 (patch) | |
tree | 239505fa04b1012bfccad56d6cc3f7f6517bfe78 /src/evalfunc.c | |
parent | f92cfb1acc3fef74eef0c83c1a35a2b6a9f93a9b (diff) |
patch 9.0.0331: cannot use items() on a stringv9.0.0331
Problem: Cannot use items() on a string.
Solution: Make items() work on a string. (closes #11016)
Diffstat (limited to 'src/evalfunc.c')
-rw-r--r-- | src/evalfunc.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c index c43db65b95..92c3269ef8 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -902,7 +902,7 @@ arg_slice1(type_T *type, type_T *decl_type UNUSED, argcontext_T *context) * or any) */ static int -arg_count1(type_T *type, type_T *decl_type UNUSED, argcontext_T *context) +arg_string_or_list_or_dict(type_T *type, type_T *decl_type UNUSED, argcontext_T *context) { if (type->tt_type == VAR_ANY || type->tt_type == VAR_UNKNOWN @@ -911,7 +911,8 @@ arg_count1(type_T *type, type_T *decl_type UNUSED, argcontext_T *context) || type->tt_type == VAR_DICT) return OK; - arg_type_mismatch(&t_string, type, context->arg_idx + 1); + semsg(_(e_string_list_or_dict_required_for_argument_nr), + context->arg_idx + 1); return FAIL; } @@ -950,6 +951,7 @@ static argcheck_T arg1_list_number[] = {arg_list_number}; static argcheck_T arg1_list_or_blob[] = {arg_list_or_blob}; static argcheck_T arg1_list_or_dict[] = {arg_list_or_dict}; static argcheck_T arg1_list_string[] = {arg_list_string}; +static argcheck_T arg1_string_or_list_or_dict[] = {arg_string_or_list_or_dict}; static argcheck_T arg1_lnum[] = {arg_lnum}; static argcheck_T arg1_number[] = {arg_number}; static argcheck_T arg1_string[] = {arg_string}; @@ -1028,7 +1030,7 @@ static argcheck_T arg34_assert_inrange[] = {arg_float_or_nr, arg_float_or_nr, ar static argcheck_T arg4_browse[] = {arg_bool, arg_string, arg_string, arg_string}; static argcheck_T arg23_chanexpr[] = {arg_chan_or_job, NULL, arg_dict_any}; static argcheck_T arg23_chanraw[] = {arg_chan_or_job, arg_string_or_blob, arg_dict_any}; -static argcheck_T arg24_count[] = {arg_count1, NULL, arg_bool, arg_number}; +static argcheck_T arg24_count[] = {arg_string_or_list_or_dict, NULL, arg_bool, arg_number}; static argcheck_T arg13_cursor[] = {arg_cursor1, arg_number, arg_number}; static argcheck_T arg12_deepcopy[] = {NULL, arg_bool}; static argcheck_T arg12_execute[] = {arg_string_or_list_string, arg_string}; @@ -2029,7 +2031,7 @@ static funcentry_T global_functions[] = ret_number_bool, f_islocked}, {"isnan", 1, 1, FEARG_1, arg1_float_or_nr, ret_number_bool, MATH_FUNC(f_isnan)}, - {"items", 1, 1, FEARG_1, arg1_list_or_dict, + {"items", 1, 1, FEARG_1, arg1_string_or_list_or_dict, ret_list_items, f_items}, {"job_getchannel", 1, 1, FEARG_1, arg1_job, ret_channel, JOB_FUNC(f_job_getchannel)}, |