diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-12-01 21:08:05 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-12-01 21:08:05 +0100 |
commit | 57cf4973a283941c92744554474b2c52ce892fd1 (patch) | |
tree | 8b151e68e17a6b8f0f3787f30f6d9750e8895b44 | |
parent | 4324d87a4432721d9dbc72c1e336350bc6b7ebc3 (diff) | |
download | vim-git-57cf4973a283941c92744554474b2c52ce892fd1.tar.gz |
patch 8.2.2075: error for const argument to mapnew()v8.2.2075
Problem: Error for const argument to mapnew().
Solution: Don't give an error. (closes #7400)
-rw-r--r-- | src/list.c | 6 | ||||
-rw-r--r-- | src/testdir/test_filter_map.vim | 6 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 11 insertions, 3 deletions
diff --git a/src/list.c b/src/list.c index c364fa72f..6285e01d5 100644 --- a/src/list.c +++ b/src/list.c @@ -2065,7 +2065,7 @@ filter_map(typval_T *argvars, typval_T *rettv, filtermap_T filtermap) --todo; di = HI2DI(hi); - if (filtermap != FILTERMAP_FILTER + if (filtermap == FILTERMAP_MAP && (value_check_lock(di->di_tv.v_lock, arg_errmsg, TRUE) || var_check_ro(di->di_flags, @@ -2225,12 +2225,12 @@ filter_map(typval_T *argvars, typval_T *rettv, filtermap_T filtermap) } else { - // Materialized list from range(): loop over the items + // Materialized list: loop over the items for (li = l->lv_first; li != NULL; li = nli) { typval_T newtv; - if (filtermap != FILTERMAP_FILTER && value_check_lock( + if (filtermap == FILTERMAP_MAP && value_check_lock( li->li_tv.v_lock, arg_errmsg, TRUE)) break; nli = li->li_next; diff --git a/src/testdir/test_filter_map.vim b/src/testdir/test_filter_map.vim index e88f755b9..a9ff35e1b 100644 --- a/src/testdir/test_filter_map.vim +++ b/src/testdir/test_filter_map.vim @@ -123,6 +123,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() @@ -130,6 +133,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() diff --git a/src/version.c b/src/version.c index 469b92d31..bbbf9f23e 100644 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2075, +/**/ 2074, /**/ 2073, |