summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-02-23 21:03:32 +0000
committerBram Moolenaar <Bram@vim.org>2022-02-23 21:03:32 +0000
commitfa02616718103be3f9e13e26d57905d4eddf836d (patch)
tree5c1703f53990c916b5a9af0b2880088068fe7cff
parent6e1a38745f794715dc624399c318f513b54797c4 (diff)
downloadvim-git-fa02616718103be3f9e13e26d57905d4eddf836d.tar.gz
patch 8.2.4459: Vim9: compiling sort() call fails with unknown argumentsv8.2.4459
Problem: Vim9: compiling sort() call fails with a funcref that has unknown arguments. Solution: Do not check the arguments if they are unknown at compile time. (closes #9835)
-rw-r--r--src/evalfunc.c2
-rw-r--r--src/testdir/test_vim9_builtin.vim11
-rw-r--r--src/version.c2
3 files changed, 15 insertions, 0 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c
index e8ed4bab0..1b9320036 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -624,6 +624,8 @@ arg_sort_how(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
where_T where = WHERE_INIT;
args[1] = args[0];
+ if (type->tt_argcount == -1)
+ t_func_exp.tt_argcount = -1;
where.wt_index = 2;
return check_type(&t_func_exp, type, TRUE, where);
}
diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim
index dfec991f8..7577aecd2 100644
--- a/src/testdir/test_vim9_builtin.vim
+++ b/src/testdir/test_vim9_builtin.vim
@@ -3812,6 +3812,17 @@ def Test_sort_argument()
sort([1, 2, 3], (a: any, b: any) => 1)
END
v9.CheckDefAndScriptSuccess(lines)
+
+ lines =<< trim END
+ vim9script
+ def SortedList(): list<number>
+ var Lambda: func: number = (a, b): number => a - b
+ var l = [3, 2, 1]
+ return l->sort(Lambda)
+ enddef
+ SortedList()->assert_equal([1, 2, 3])
+ END
+ v9.CheckScriptSuccess(lines)
enddef
def Test_sort_compare_func_fails()
diff --git a/src/version.c b/src/version.c
index 800925df9..f8fb3139c 100644
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 4459,
+/**/
4458,
/**/
4457,