Patch 9.0.1660
Problem:    Error for using matchfuzzy() in Vim9 script returning a list of
            dicts.
Solution:   Make return type of matchfuzzy() list<any>. (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<any> but got list<unknown>', '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<dict<any>> = matchfuzzy(items, 'abc', {key: 'name'})
+     assert_equal([{name: 'abc', id: 3}], l)
+     var k: list<string> = 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<any> but got list<unknown>', '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<dict<any>> = matchfuzzypos(items, 'abc', {key: 'name'})[0]
+     assert_equal([{name: 'abc', id: 3}], l)
+     var k: list<string> = 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 -- b...@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    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20230624154256.C02311C054C%40moolenaar.net.

Raspunde prin e-mail lui