mirror of
https://github.com/vim/vim.git
synced 2025-07-04 23:07:33 -04:00
patch 8.2.3142: Vim9: type check for has_key() argument is too strict
Problem: Vim9: type check for has_key() argument is too strict. Solution: Also allow for a number key argument. (closes #8542)
This commit is contained in:
parent
de69a7353e
commit
1aeddeb8bd
@ -446,6 +446,7 @@ argcheck_T arg2_number[] = {arg_number, arg_number};
|
||||
argcheck_T arg2_string[] = {arg_string, arg_string};
|
||||
argcheck_T arg2_list_nr[] = {arg_list_number, arg_list_number};
|
||||
argcheck_T arg2_dict_string[] = {arg_dict_any, arg_string};
|
||||
argcheck_T arg2_dict_string_or_nr[] = {arg_dict_any, arg_string_or_nr};
|
||||
argcheck_T arg2_string_dict[] = {arg_string, arg_dict_any};
|
||||
argcheck_T arg2_listblob_item[] = {arg_list_or_blob, arg_item_of_prev};
|
||||
argcheck_T arg2_execute[] = {arg_string_or_list, arg_string};
|
||||
@ -1109,7 +1110,7 @@ static funcentry_T global_functions[] =
|
||||
ret_any, f_globpath},
|
||||
{"has", 1, 2, 0, NULL,
|
||||
ret_number_bool, f_has},
|
||||
{"has_key", 2, 2, FEARG_1, arg2_dict_string,
|
||||
{"has_key", 2, 2, FEARG_1, arg2_dict_string_or_nr,
|
||||
ret_number_bool, f_has_key},
|
||||
{"haslocaldir", 0, 2, FEARG_1, arg2_number,
|
||||
ret_number, f_haslocaldir},
|
||||
|
@ -1131,6 +1131,12 @@ def Test_has()
|
||||
enddef
|
||||
|
||||
def Test_has_key()
|
||||
var d = {123: 'xx'}
|
||||
assert_true(has_key(d, '123'))
|
||||
assert_true(has_key(d, 123))
|
||||
assert_false(has_key(d, 'x'))
|
||||
assert_false(has_key(d, 99))
|
||||
|
||||
CheckDefAndScriptFailure2(['has_key([1, 2], "k")'], 'E1013: Argument 1: type mismatch, expected dict<any> but got list<number>', 'E715: Dictionary required')
|
||||
CheckDefAndScriptFailure2(['has_key({"a": 10}, ["a"])'], 'E1013: Argument 2: type mismatch, expected string but got list<string>', 'E730: Using a List as a String')
|
||||
enddef
|
||||
|
@ -755,6 +755,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
3142,
|
||||
/**/
|
||||
3141,
|
||||
/**/
|
||||
|
Loading…
x
Reference in New Issue
Block a user