summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-05-09 14:12:14 +0100
committerBram Moolenaar <Bram@vim.org>2022-05-09 14:12:14 +0100
commit2ac037f54bb2588b7a86e61c9c6e9504884edbec (patch)
treece78bdd9ba927c3af00c5b05263a63f1a157affe
parent51f0bc31d3cf512508419064faac0e5b7e52c98b (diff)
patch 8.2.4927: return type of remove() incorrect when using three argumentsv8.2.4927
Problem: Return type of remove() incorrect when using three arguments. Solution: Use first argument type when there are three arguments. (closes #10387)
-rw-r--r--src/evalfunc.c7
-rw-r--r--src/testdir/test_vim9_builtin.vim11
-rw-r--r--src/version.c2
3 files changed, 13 insertions, 7 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c
index efade6cab6..f7a04fdc98 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -1420,13 +1420,18 @@ ret_argv(int argcount,
static type_T *
ret_remove(int argcount,
type2_T *argtypes,
- type_T **decl_type UNUSED)
+ type_T **decl_type)
{
if (argcount > 0)
{
if (argtypes[0].type_curr->tt_type == VAR_LIST
|| argtypes[0].type_curr->tt_type == VAR_DICT)
{
+ if (argcount == 3)
+ {
+ *decl_type = argtypes[0].type_decl;
+ return argtypes[0].type_curr;
+ }
if (argtypes[0].type_curr->tt_type
== argtypes[0].type_decl->tt_type)
*decl_type = argtypes[0].type_decl->tt_member;
diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim
index c9334bc0f5..2c4e9ae99c 100644
--- a/src/testdir/test_vim9_builtin.vim
+++ b/src/testdir/test_vim9_builtin.vim
@@ -3208,12 +3208,11 @@ def Test_remove()
enddef
def Test_remove_return_type()
- var l = remove({one: [1, 2], two: [3, 4]}, 'one')
- var res = 0
- for n in l
- res += n
- endfor
- res->assert_equal(3)
+ var l: list<number> = remove({one: [1, 2], two: [3, 4]}, 'one')
+ l->assert_equal([1, 2])
+
+ var ll: list<number> = remove(range(3), 0, 1)
+ ll->assert_equal([0, 1])
enddef
def Test_rename()
diff --git a/src/version.c b/src/version.c
index c23757fe23..54eb6521b8 100644
--- a/src/version.c
+++ b/src/version.c
@@ -747,6 +747,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 4927,
+/**/
4926,
/**/
4925,