forked from aniani/vim
patch 8.2.3911: Vim9: type check for filter() does not accept unknown
Problem: Vim9: type check for filter() does not accept unknown. Solution: Also accept unknown for the return type. (closes #9413)
This commit is contained in:
@@ -494,6 +494,7 @@ arg_filter_func(type_T *type, argcontext_T *context)
|
||||
if (type->tt_type == VAR_FUNC
|
||||
&& !(type->tt_member->tt_type == VAR_BOOL
|
||||
|| type->tt_member->tt_type == VAR_NUMBER
|
||||
|| type->tt_member->tt_type == VAR_UNKNOWN
|
||||
|| type->tt_member->tt_type == VAR_ANY))
|
||||
{
|
||||
arg_type_mismatch(&t_func_bool, type, context->arg_idx + 1);
|
||||
|
||||
@@ -1253,6 +1253,12 @@ def Test_filter()
|
||||
assert_equal([], filter([1, 2, 3], '0'))
|
||||
assert_equal([1, 2, 3], filter([1, 2, 3], '1'))
|
||||
assert_equal({b: 20}, filter({a: 10, b: 20}, 'v:val == 20'))
|
||||
|
||||
def GetFiltered(): list<number>
|
||||
var Odd: func = (_, v) => v % 2
|
||||
return range(3)->filter(Odd)
|
||||
enddef
|
||||
assert_equal([1], GetFiltered())
|
||||
enddef
|
||||
|
||||
def Test_filter_wrong_dict_key_type()
|
||||
|
||||
@@ -749,6 +749,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
3911,
|
||||
/**/
|
||||
3910,
|
||||
/**/
|
||||
|
||||
Reference in New Issue
Block a user