To: vim_dev@googlegroups.com Subject: Patch 8.2.3142 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3142 Problem: Vim9: type check for has_key() argument is too strict. Solution: Also allow for a number key argument. (closes #8542) Files: src/evalfunc.c, src/testdir/test_vim9_builtin.vim *** ../vim-8.2.3141/src/evalfunc.c 2021-07-10 21:28:55.327050110 +0200 --- src/evalfunc.c 2021-07-11 14:52:12.241630427 +0200 *************** *** 446,451 **** --- 446,452 ---- 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,1115 **** ret_any, f_globpath}, {"has", 1, 2, 0, NULL, ret_number_bool, f_has}, ! {"has_key", 2, 2, FEARG_1, arg2_dict_string, ret_number_bool, f_has_key}, {"haslocaldir", 0, 2, FEARG_1, arg2_number, ret_number, f_haslocaldir}, --- 1110,1116 ---- ret_any, f_globpath}, {"has", 1, 2, 0, NULL, ret_number_bool, f_has}, ! {"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}, *** ../vim-8.2.3141/src/testdir/test_vim9_builtin.vim 2021-07-10 13:15:35.295053013 +0200 --- src/testdir/test_vim9_builtin.vim 2021-07-11 14:54:03.373492091 +0200 *************** *** 1131,1136 **** --- 1131,1142 ---- 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 but got list', 'E715: Dictionary required') CheckDefAndScriptFailure2(['has_key({"a": 10}, ["a"])'], 'E1013: Argument 2: type mismatch, expected string but got list', 'E730: Using a List as a String') enddef *** ../vim-8.2.3141/src/version.c 2021-07-11 14:28:19.943563551 +0200 --- src/version.c 2021-07-11 14:55:22.989386953 +0200 *************** *** 757,758 **** --- 757,760 ---- { /* Add new patch number below this line */ + /**/ + 3142, /**/ -- hundred-and-one symptoms of being an internet addict: 115. You are late picking up your kid from school and try to explain to the teacher you were stuck in Web traffic. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///