forked from aniani/vim
patch 8.2.4458: Vim9: compiling filter() call fails with unknown arguments
Problem: Vim9: compiling filter() call fails with funcref that has unknown
arguments.
Solution: Do not check the arguments if they are unknown at compile time.
(closes #9835)
This commit is contained in:
@@ -552,6 +552,8 @@ check_map_filter_arg2(type_T *type, argcontext_T *context, int is_map)
|
||||
t_func_exp.tt_member = &t_bool;
|
||||
if (args[0] == NULL)
|
||||
args[0] = &t_unknown;
|
||||
if (type->tt_argcount == -1)
|
||||
t_func_exp.tt_argcount = -1;
|
||||
|
||||
where.wt_index = 2;
|
||||
return check_type(&t_func_exp, type, TRUE, where);
|
||||
|
||||
@@ -1340,10 +1340,21 @@ def Test_filter()
|
||||
enddef
|
||||
assert_equal([1], GetFiltered())
|
||||
|
||||
var lines =<< trim END
|
||||
vim9script
|
||||
def Func(): list<string>
|
||||
var MatchWord: func: bool = (_, v) => true
|
||||
var l = ['xxx']
|
||||
return l->filter(MatchWord)
|
||||
enddef
|
||||
assert_equal(['xxx'], Func())
|
||||
END
|
||||
v9.CheckScriptSuccess(lines)
|
||||
|
||||
v9.CheckDefAndScriptFailure(['filter(1.1, "1")'], ['E1013: Argument 1: type mismatch, expected list<any> but got float', 'E1251: List, Dictionary, Blob or String required for argument 1'])
|
||||
v9.CheckDefAndScriptFailure(['filter([1, 2], 4)'], ['E1256: String or function required for argument 2', 'E1024: Using a Number as a String'])
|
||||
|
||||
var lines =<< trim END
|
||||
lines =<< trim END
|
||||
def F(i: number, v: any): string
|
||||
return 'bad'
|
||||
enddef
|
||||
|
||||
@@ -754,6 +754,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
4458,
|
||||
/**/
|
||||
4457,
|
||||
/**/
|
||||
|
||||
Reference in New Issue
Block a user