To: vim_dev@googlegroups.com Subject: Patch 9.0.1660 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.1660 Problem: Error for using matchfuzzy() in Vim9 script returning a list of dicts. Solution: Make return type of matchfuzzy() list. (Yegappan Lakshmanan, closes #12574) Files: src/evalfunc.c, src/testdir/test_vim9_builtin.vim *** ../vim-9.0.1659/src/evalfunc.c 2023-06-08 17:09:40.188768829 +0100 --- src/evalfunc.c 2023-06-24 16:36:31.163300863 +0100 *************** *** 2224,2230 **** {"matchend", 2, 4, FEARG_1, arg24_match_func, ret_number, f_matchend}, {"matchfuzzy", 2, 3, FEARG_1, arg3_list_string_dict, ! ret_list_string, f_matchfuzzy}, {"matchfuzzypos", 2, 3, FEARG_1, arg3_list_string_dict, ret_list_any, f_matchfuzzypos}, {"matchlist", 2, 4, FEARG_1, arg24_match_func, --- 2224,2230 ---- {"matchend", 2, 4, FEARG_1, arg24_match_func, ret_number, f_matchend}, {"matchfuzzy", 2, 3, FEARG_1, arg3_list_string_dict, ! ret_list_any, f_matchfuzzy}, {"matchfuzzypos", 2, 3, FEARG_1, arg3_list_string_dict, ret_list_any, f_matchfuzzypos}, {"matchlist", 2, 4, FEARG_1, arg24_match_func, *** ../vim-9.0.1659/src/testdir/test_vim9_builtin.vim 2023-06-14 16:39:48.657873849 +0100 --- src/testdir/test_vim9_builtin.vim 2023-06-24 16:36:31.163300863 +0100 *************** *** 2821,2826 **** --- 2821,2835 ---- v9.CheckDefAndScriptFailure(['matchfuzzy([], 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) v9.CheckDefAndScriptFailure(['matchfuzzy([], "a", [])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) matchfuzzy(['abc', 'xyz'], '')->assert_equal([]) + var lines =<< trim END + var items = [{name: 'xyz', id: 1}, {name: 'def', id: 2}, + {name: 'abc', id: 3}] + var l: list> = matchfuzzy(items, 'abc', {key: 'name'}) + assert_equal([{name: 'abc', id: 3}], l) + var k: list = matchfuzzy(['one', 'two', 'who'], 'o') + assert_equal(['one', 'two', 'who'], k) + END + v9.CheckDefAndScriptSuccess(lines) enddef def Test_matchfuzzypos() *************** *** 2828,2833 **** --- 2837,2851 ---- v9.CheckDefAndScriptFailure(['matchfuzzypos([], 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) v9.CheckDefAndScriptFailure(['matchfuzzypos([], "a", [])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) matchfuzzypos(['abc', 'xyz'], '')->assert_equal([[], [], []]) + var lines =<< trim END + var items = [{name: 'xyz', id: 1}, {name: 'def', id: 2}, + {name: 'abc', id: 3}] + var l: list> = matchfuzzypos(items, 'abc', {key: 'name'})[0] + assert_equal([{name: 'abc', id: 3}], l) + var k: list = matchfuzzypos(['one', 'two', 'who'], 'o')[0] + assert_equal(['one', 'two', 'who'], k) + END + v9.CheckDefAndScriptSuccess(lines) enddef def Test_matchlist() *** ../vim-9.0.1659/src/version.c 2023-06-24 14:19:49.879867855 +0100 --- src/version.c 2023-06-24 16:38:58.871047007 +0100 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 1660, /**/ -- hundred-and-one symptoms of being an internet addict: 228. You spend Saturday night making the counter on your home page pass that 2000 mark. /// 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 ///