Patch 8.2.1701
Problem: Vim9: sort("i") does not work.
Solution: Don't try getting a number for a string argument. (closes #6958)
Files: src/list.c, src/testdir/test_vim9_func.vim
*** ../vim-8.2.1700/src/list.c 2020-09-16 21:08:23.642361197 +0200
--- src/list.c 2020-09-16 23:22:06.835343624 +0200
***************
*** 1717,1734 ****
else
{
int error = FALSE;
! i = (long)tv_get_number_chk(&argvars[1], &error);
! if (error)
! goto theend; // type error; errmsg already given
! if (i == 1)
! info.item_compare_ic = TRUE;
! else if (argvars[1].v_type != VAR_NUMBER)
! info.item_compare_func = tv_get_string(&argvars[1]);
! else if (i != 0)
{
! emsg(_(e_invarg));
! goto theend;
}
if (info.item_compare_func != NULL)
{
--- 1717,1741 ----
else
{
int error = FALSE;
+ int nr = 0;
! if (argvars[1].v_type == VAR_NUMBER)
{
! nr = tv_get_number_chk(&argvars[1], &error);
! if (error)
! goto theend; // type error; errmsg already given
! if (nr == 1)
! info.item_compare_ic = TRUE;
! }
! if (nr != 1)
! {
! if (argvars[1].v_type != VAR_NUMBER)
! info.item_compare_func = tv_get_string(&argvars[1]);
! else if (nr != 0)
! {
! emsg(_(e_invarg));
! goto theend;
! }
}
if (info.item_compare_func != NULL)
{
*** ../vim-8.2.1700/src/testdir/test_vim9_func.vim 2020-09-16 17:55:36.537602345 +0200
--- src/testdir/test_vim9_func.vim 2020-09-16 23:10:18.026056574 +0200
***************
*** 1299,1304 ****
--- 1299,1309 ----
res = [1, 2, 3]->sort()
enddef
+ def Test_sort_argument()
+ let res = ['b', 'a', 'c']->sort('i')
+ res->assert_equal(['a', 'b', 'c'])
+ enddef
+
def Test_getqflist_return_type()
let l = getqflist()
l->assert_equal([])
*** ../vim-8.2.1700/src/version.c 2020-09-16 22:29:49.441083728 +0200
--- src/version.c 2020-09-16 23:11:43.629790551 +0200
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 1701,
/**/
--
This message contains 78% recycled characters.
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language --
http://www.Zimbu.org ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///