Patch 8.2.2075
Problem: Error for const argument to mapnew().
Solution: Don't give an error. (closes #7400)
Files: src/list.c, src/testdir/test_filter_map.vim
*** ../vim-8.2.2074/src/list.c 2020-11-28 20:32:26.086679786 +0100
--- src/list.c 2020-12-01 21:05:34.618079906 +0100
***************
*** 2065,2071 ****
--todo;
di = HI2DI(hi);
! if (filtermap != FILTERMAP_FILTER
&& (value_check_lock(di->di_tv.v_lock,
arg_errmsg, TRUE)
|| var_check_ro(di->di_flags,
--- 2065,2071 ----
--todo;
di = HI2DI(hi);
! if (filtermap == FILTERMAP_MAP
&& (value_check_lock(di->di_tv.v_lock,
arg_errmsg, TRUE)
|| var_check_ro(di->di_flags,
***************
*** 2225,2236 ****
}
else
{
! // Materialized list from range(): loop over the items
for (li = l->lv_first; li != NULL; li = nli)
{
typval_T newtv;
! if (filtermap != FILTERMAP_FILTER && value_check_lock(
li->li_tv.v_lock, arg_errmsg, TRUE))
break;
nli = li->li_next;
--- 2225,2236 ----
}
else
{
! // Materialized list: loop over the items
for (li = l->lv_first; li != NULL; li = nli)
{
typval_T newtv;
! if (filtermap == FILTERMAP_MAP && value_check_lock(
li->li_tv.v_lock, arg_errmsg, TRUE))
break;
nli = li->li_next;
*** ../vim-8.2.2074/src/testdir/test_filter_map.vim 2020-11-09 18:31:30.548791857 +0100
--- src/testdir/test_filter_map.vim 2020-12-01 21:05:04.838176761 +0100
***************
*** 123,128 ****
--- 123,131 ----
let dout = mapnew(din, {k, v -> string(v)})
call assert_equal(#{one: 1, two: 2}, din)
call assert_equal(#{one: '1', two: '2'}, dout)
+
+ const dconst = #{one: 1, two: 2, three: 3}
+ call assert_equal(#{one: 2, two: 3, three: 4}, mapnew(dconst, {_, v -> v + 1}))
endfunc
func Test_mapnew_list()
***************
*** 130,135 ****
--- 133,141 ----
let lout = mapnew(lin, {k, v -> string(v)})
call assert_equal([1, 2, 3], lin)
call assert_equal(['1', '2', '3'], lout)
+
+ const lconst = [1, 2, 3]
+ call assert_equal([2, 3, 4], mapnew(lconst, {_, v -> v + 1}))
endfunc
func Test_mapnew_blob()
*** ../vim-8.2.2074/src/version.c 2020-12-01 20:12:20.792108768 +0100
--- src/version.c 2020-12-01 21:03:57.186396221 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2075,
/**/
--
FATHER: You only killed the bride's father - that's all -
LAUNCELOT: Oh dear, I didn't really mean to...
FATHER: Didn't mean to? You put your sword right through his head!
LAUNCELOT: Gosh - Is he all right?
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// 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 ///