diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-12-27 12:29:19 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-12-27 12:29:19 +0000 |
commit | ef8f04b1d1daf2e0be8fa38dedcae84ebfc5ffb4 (patch) | |
tree | ead387b1ef5b11f9c7a64da3d4fa53309bb5f0ea /src | |
parent | 23018f2d4b6f85512af117d346eee9b14a4637a6 (diff) | |
download | vim-git-ef8f04b1d1daf2e0be8fa38dedcae84ebfc5ffb4.tar.gz |
patch 8.2.3911: Vim9: type check for filter() does not accept unknownv8.2.3911
Problem: Vim9: type check for filter() does not accept unknown.
Solution: Also accept unknown for the return type. (closes #9413)
Diffstat (limited to 'src')
-rw-r--r-- | src/evalfunc.c | 1 | ||||
-rw-r--r-- | src/testdir/test_vim9_builtin.vim | 6 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 9 insertions, 0 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c index d78589c6d..f3105200f 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -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); diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim index 6cad1e4cc..bc59e3af1 100644 --- a/src/testdir/test_vim9_builtin.vim +++ b/src/testdir/test_vim9_builtin.vim @@ -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() diff --git a/src/version.c b/src/version.c index 8c4377b1e..0d99bb857 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3911, +/**/ 3910, /**/ 3909, |