Patch 8.2.1852
Problem: map() returing zero for NULL list is unexpected.
Solution: Return the empty list. (closes #7133)
Files: src/list.c, src/testdir/test_filter_map.vim,
src/testdir/test_blob.vim
*** ../vim-8.2.1851/src/list.c 2020-10-10 15:37:54.190275246 +0200
--- src/list.c 2020-10-15 22:24:53.139931358 +0200
***************
*** 1961,1966 ****
--- 1961,1969 ----
int save_did_emsg;
int idx = 0;
+ // Always return the first argument, also on failure.
+ copy_tv(&argvars[0], rettv);
+
if (argvars[0].v_type == VAR_BLOB)
{
if ((b = argvars[0].vval.v_blob) == NULL)
***************
*** 2110,2117 ****
did_emsg |= save_did_emsg;
}
-
- copy_tv(&argvars[0], rettv);
}
/*
--- 2113,2118 ----
*** ../vim-8.2.1851/src/testdir/test_filter_map.vim 2020-08-03
22:39:05.902971252 +0200
--- src/testdir/test_filter_map.vim 2020-10-15 22:14:49.167212670 +0200
***************
*** 98,107 ****
call assert_fails("let l = filter([1, 2, 3], '{}')", 'E728:')
call assert_fails("let l = filter({'k' : 10}, '{}')", 'E728:')
call assert_fails("let l = filter([1, 2], {})", 'E731:')
! call assert_equal(0, filter(test_null_list(), 0))
! call assert_equal(0, filter(test_null_dict(), 0))
! call assert_equal(0, map(test_null_list(), '"> " .. v:val'))
! call assert_equal(0, map(test_null_dict(), '"> " .. v:val'))
call assert_equal([1, 2, 3], filter([1, 2, 3], test_null_function()))
call assert_fails("let l = filter([1, 2], function('min'))", 'E118:')
call assert_equal([1, 2, 3], filter([1, 2, 3], test_null_partial()))
--- 98,107 ----
call assert_fails("let l = filter([1, 2, 3], '{}')", 'E728:')
call assert_fails("let l = filter({'k' : 10}, '{}')", 'E728:')
call assert_fails("let l = filter([1, 2], {})", 'E731:')
! call assert_equal(test_null_list(), filter(test_null_list(), 0))
! call assert_equal(test_null_dict(), filter(test_null_dict(), 0))
! call assert_equal(test_null_list(), map(test_null_list(), '"> " .. v:val'))
! call assert_equal(test_null_dict(), map(test_null_dict(), '"> " .. v:val'))
call assert_equal([1, 2, 3], filter([1, 2, 3], test_null_function()))
call assert_fails("let l = filter([1, 2], function('min'))", 'E118:')
call assert_equal([1, 2, 3], filter([1, 2, 3], test_null_partial()))
*** ../vim-8.2.1851/src/testdir/test_blob.vim 2020-06-20 16:05:29.012185251
+0200
--- src/testdir/test_blob.vim 2020-10-15 22:18:13.717988068 +0200
***************
*** 271,276 ****
--- 271,277 ----
" filter() item in blob
func Test_blob_filter()
+ call assert_equal(test_null_blob(), filter(test_null_blob(), '0'))
call assert_equal(0z, filter(0zDEADBEEF, '0'))
call assert_equal(0zADBEEF, filter(0zDEADBEEF, 'v:val != 0xDE'))
call assert_equal(0zDEADEF, filter(0zDEADBEEF, 'v:val != 0xBE'))
*** ../vim-8.2.1851/src/version.c 2020-10-15 21:54:51.792563655 +0200
--- src/version.c 2020-10-15 22:14:36.671292934 +0200
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 1852,
/**/
--
>From "know your smileys":
|-P Reaction to unusually ugly C code
/// Bram Moolenaar -- [email protected] -- 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 ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202010152029.09FKTrhA174330%40masaka.moolenaar.net.