forked from aniani/vim
patch 9.0.1660: error for using matchfuzzy() returning a list of dicts
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)
This commit is contained in:
committed by
Bram Moolenaar
parent
279de0cd1f
commit
2d8e998544
@@ -2224,7 +2224,7 @@ static funcentry_T global_functions[] =
|
|||||||
{"matchend", 2, 4, FEARG_1, arg24_match_func,
|
{"matchend", 2, 4, FEARG_1, arg24_match_func,
|
||||||
ret_number, f_matchend},
|
ret_number, f_matchend},
|
||||||
{"matchfuzzy", 2, 3, FEARG_1, arg3_list_string_dict,
|
{"matchfuzzy", 2, 3, FEARG_1, arg3_list_string_dict,
|
||||||
ret_list_string, f_matchfuzzy},
|
ret_list_any, f_matchfuzzy},
|
||||||
{"matchfuzzypos", 2, 3, FEARG_1, arg3_list_string_dict,
|
{"matchfuzzypos", 2, 3, FEARG_1, arg3_list_string_dict,
|
||||||
ret_list_any, f_matchfuzzypos},
|
ret_list_any, f_matchfuzzypos},
|
||||||
{"matchlist", 2, 4, FEARG_1, arg24_match_func,
|
{"matchlist", 2, 4, FEARG_1, arg24_match_func,
|
||||||
|
@@ -2821,6 +2821,15 @@ def Test_matchfuzzy()
|
|||||||
v9.CheckDefAndScriptFailure(['matchfuzzy([], 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
|
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'])
|
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([])
|
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
|
enddef
|
||||||
|
|
||||||
def Test_matchfuzzypos()
|
def Test_matchfuzzypos()
|
||||||
@@ -2828,6 +2837,15 @@ def Test_matchfuzzypos()
|
|||||||
v9.CheckDefAndScriptFailure(['matchfuzzypos([], 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
|
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'])
|
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([[], [], []])
|
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
|
enddef
|
||||||
|
|
||||||
def Test_matchlist()
|
def Test_matchlist()
|
||||||
|
@@ -695,6 +695,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1660,
|
||||||
/**/
|
/**/
|
||||||
1659,
|
1659,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user