mirror of
https://github.com/neovim/neovim.git
synced 2025-09-17 00:38:17 +00:00
vim-patch:8.2.2075: error for const argument to mapnew()
Problem: Error for const argument to mapnew().
Solution: Don't give an error. (closes vim/vim#7400)
57cf4973a2
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
@@ -5115,7 +5115,7 @@ static void filter_map(typval_T *argvars, typval_T *rettv, filtermap_T filtermap
|
||||
todo--;
|
||||
|
||||
dictitem_T *di = TV_DICT_HI2DI(hi);
|
||||
if (filtermap != FILTERMAP_FILTER
|
||||
if (filtermap == FILTERMAP_MAP
|
||||
&& (value_check_lock(di->di_tv.v_lock, arg_errmsg, TV_TRANSLATE)
|
||||
|| var_check_ro(di->di_flags, arg_errmsg, TV_TRANSLATE))) {
|
||||
break;
|
||||
@@ -5210,7 +5210,7 @@ static void filter_map(typval_T *argvars, typval_T *rettv, filtermap_T filtermap
|
||||
tv_list_set_lock(l, VAR_LOCKED);
|
||||
}
|
||||
for (listitem_T *li = tv_list_first(l); li != NULL;) {
|
||||
if (filtermap != FILTERMAP_FILTER
|
||||
if (filtermap == FILTERMAP_MAP
|
||||
&& value_check_lock(TV_LIST_ITEM_TV(li)->v_lock, arg_errmsg,
|
||||
TV_TRANSLATE)) {
|
||||
break;
|
||||
|
@@ -116,6 +116,9 @@ func Test_mapnew_dict()
|
||||
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()
|
||||
@@ -123,6 +126,9 @@ func Test_mapnew_list()
|
||||
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()
|
||||
|
Reference in New Issue
Block a user