Mercurial > vim
comparison src/evalfunc.c @ 29986:0ad8b72af148 v9.0.0331
patch 9.0.0331: cannot use items() on a string
Commit: https://github.com/vim/vim/commit/3e518a8ec74065aedd67d352c93d6ae6be550316
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Aug 30 17:45:33 2022 +0100
patch 9.0.0331: cannot use items() on a string
Problem: Cannot use items() on a string.
Solution: Make items() work on a string. (closes https://github.com/vim/vim/issues/11016)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 30 Aug 2022 19:00:03 +0200 |
parents | 34151eb6ae25 |
children | 86eb4aba16c3 |
comparison
equal
deleted
inserted
replaced
29985:2860987502c1 | 29986:0ad8b72af148 |
---|---|
900 /* | 900 /* |
901 * Check "type" which is the first argument of count() (string or list or dict | 901 * Check "type" which is the first argument of count() (string or list or dict |
902 * or any) | 902 * or any) |
903 */ | 903 */ |
904 static int | 904 static int |
905 arg_count1(type_T *type, type_T *decl_type UNUSED, argcontext_T *context) | 905 arg_string_or_list_or_dict(type_T *type, type_T *decl_type UNUSED, argcontext_T *context) |
906 { | 906 { |
907 if (type->tt_type == VAR_ANY | 907 if (type->tt_type == VAR_ANY |
908 || type->tt_type == VAR_UNKNOWN | 908 || type->tt_type == VAR_UNKNOWN |
909 || type->tt_type == VAR_STRING | 909 || type->tt_type == VAR_STRING |
910 || type->tt_type == VAR_LIST | 910 || type->tt_type == VAR_LIST |
911 || type->tt_type == VAR_DICT) | 911 || type->tt_type == VAR_DICT) |
912 return OK; | 912 return OK; |
913 | 913 |
914 arg_type_mismatch(&t_string, type, context->arg_idx + 1); | 914 semsg(_(e_string_list_or_dict_required_for_argument_nr), |
915 context->arg_idx + 1); | |
915 return FAIL; | 916 return FAIL; |
916 } | 917 } |
917 | 918 |
918 /* | 919 /* |
919 * Check "type" which is the first argument of cursor() (number or string or | 920 * Check "type" which is the first argument of cursor() (number or string or |
948 static argcheck_T arg1_list_any[] = {arg_list_any}; | 949 static argcheck_T arg1_list_any[] = {arg_list_any}; |
949 static argcheck_T arg1_list_number[] = {arg_list_number}; | 950 static argcheck_T arg1_list_number[] = {arg_list_number}; |
950 static argcheck_T arg1_list_or_blob[] = {arg_list_or_blob}; | 951 static argcheck_T arg1_list_or_blob[] = {arg_list_or_blob}; |
951 static argcheck_T arg1_list_or_dict[] = {arg_list_or_dict}; | 952 static argcheck_T arg1_list_or_dict[] = {arg_list_or_dict}; |
952 static argcheck_T arg1_list_string[] = {arg_list_string}; | 953 static argcheck_T arg1_list_string[] = {arg_list_string}; |
954 static argcheck_T arg1_string_or_list_or_dict[] = {arg_string_or_list_or_dict}; | |
953 static argcheck_T arg1_lnum[] = {arg_lnum}; | 955 static argcheck_T arg1_lnum[] = {arg_lnum}; |
954 static argcheck_T arg1_number[] = {arg_number}; | 956 static argcheck_T arg1_number[] = {arg_number}; |
955 static argcheck_T arg1_string[] = {arg_string}; | 957 static argcheck_T arg1_string[] = {arg_string}; |
956 static argcheck_T arg1_string_or_list_any[] = {arg_string_or_list_any}; | 958 static argcheck_T arg1_string_or_list_any[] = {arg_string_or_list_any}; |
957 static argcheck_T arg1_string_or_list_string[] = {arg_string_or_list_string}; | 959 static argcheck_T arg1_string_or_list_string[] = {arg_string_or_list_string}; |
1026 static argcheck_T arg15_assert_fails[] = {arg_string_or_nr, arg_string_or_list_any, NULL, arg_number, arg_string}; | 1028 static argcheck_T arg15_assert_fails[] = {arg_string_or_nr, arg_string_or_list_any, NULL, arg_number, arg_string}; |
1027 static argcheck_T arg34_assert_inrange[] = {arg_float_or_nr, arg_float_or_nr, arg_float_or_nr, arg_string}; | 1029 static argcheck_T arg34_assert_inrange[] = {arg_float_or_nr, arg_float_or_nr, arg_float_or_nr, arg_string}; |
1028 static argcheck_T arg4_browse[] = {arg_bool, arg_string, arg_string, arg_string}; | 1030 static argcheck_T arg4_browse[] = {arg_bool, arg_string, arg_string, arg_string}; |
1029 static argcheck_T arg23_chanexpr[] = {arg_chan_or_job, NULL, arg_dict_any}; | 1031 static argcheck_T arg23_chanexpr[] = {arg_chan_or_job, NULL, arg_dict_any}; |
1030 static argcheck_T arg23_chanraw[] = {arg_chan_or_job, arg_string_or_blob, arg_dict_any}; | 1032 static argcheck_T arg23_chanraw[] = {arg_chan_or_job, arg_string_or_blob, arg_dict_any}; |
1031 static argcheck_T arg24_count[] = {arg_count1, NULL, arg_bool, arg_number}; | 1033 static argcheck_T arg24_count[] = {arg_string_or_list_or_dict, NULL, arg_bool, arg_number}; |
1032 static argcheck_T arg13_cursor[] = {arg_cursor1, arg_number, arg_number}; | 1034 static argcheck_T arg13_cursor[] = {arg_cursor1, arg_number, arg_number}; |
1033 static argcheck_T arg12_deepcopy[] = {NULL, arg_bool}; | 1035 static argcheck_T arg12_deepcopy[] = {NULL, arg_bool}; |
1034 static argcheck_T arg12_execute[] = {arg_string_or_list_string, arg_string}; | 1036 static argcheck_T arg12_execute[] = {arg_string_or_list_string, arg_string}; |
1035 static argcheck_T arg23_extend[] = {arg_list_or_dict, arg_same_as_prev, arg_extend3}; | 1037 static argcheck_T arg23_extend[] = {arg_list_or_dict, arg_same_as_prev, arg_extend3}; |
1036 static argcheck_T arg23_extendnew[] = {arg_list_or_dict, arg_same_struct_as_prev, arg_extend3}; | 1038 static argcheck_T arg23_extendnew[] = {arg_list_or_dict, arg_same_struct_as_prev, arg_extend3}; |
2027 ret_number, MATH_FUNC(f_isinf)}, | 2029 ret_number, MATH_FUNC(f_isinf)}, |
2028 {"islocked", 1, 1, FEARG_1, arg1_string, | 2030 {"islocked", 1, 1, FEARG_1, arg1_string, |
2029 ret_number_bool, f_islocked}, | 2031 ret_number_bool, f_islocked}, |
2030 {"isnan", 1, 1, FEARG_1, arg1_float_or_nr, | 2032 {"isnan", 1, 1, FEARG_1, arg1_float_or_nr, |
2031 ret_number_bool, MATH_FUNC(f_isnan)}, | 2033 ret_number_bool, MATH_FUNC(f_isnan)}, |
2032 {"items", 1, 1, FEARG_1, arg1_list_or_dict, | 2034 {"items", 1, 1, FEARG_1, arg1_string_or_list_or_dict, |
2033 ret_list_items, f_items}, | 2035 ret_list_items, f_items}, |
2034 {"job_getchannel", 1, 1, FEARG_1, arg1_job, | 2036 {"job_getchannel", 1, 1, FEARG_1, arg1_job, |
2035 ret_channel, JOB_FUNC(f_job_getchannel)}, | 2037 ret_channel, JOB_FUNC(f_job_getchannel)}, |
2036 {"job_info", 0, 1, FEARG_1, arg1_job, | 2038 {"job_info", 0, 1, FEARG_1, arg1_job, |
2037 ret_job_info, JOB_FUNC(f_job_info)}, | 2039 ret_job_info, JOB_FUNC(f_job_info)}, |