diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-11-06 18:27:17 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-11-06 18:27:17 +0000 |
commit | adbc08fd69433b5216e609a404d674f3e67eea9c (patch) | |
tree | 0b66f034862e8d7c40116326e64382fcafed0b7d /src/testdir/test_vim9_expr.vim | |
parent | 69a8bb8dc13571102537762b047747cc36b53d5d (diff) |
patch 9.0.0840: cannot change a slice of a const listv9.0.0840
Problem: Cannot change a slice of a const list. (Takumi KAGIYAMA)
Solution: Remove the const flag from the slice type. (closes #11490)
Diffstat (limited to 'src/testdir/test_vim9_expr.vim')
-rw-r--r-- | src/testdir/test_vim9_expr.vim | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim index bc4a790273..5a178803e4 100644 --- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -3132,6 +3132,18 @@ def Test_expr9_any_index_slice() unlet g:testlist enddef +def s:GetList(): list<string> + return ['a', 'b', 'z'] +enddef + +def Test_slice_const_list() + const list = GetList() + final sliced = list[0 : 1] + # OK to change the list after slicing, it is a copy now + add(sliced, 'Z') + assert_equal(['a', 'b', 'Z'], sliced) +enddef + def Test_expr9_const_any_index_slice() var lines =<< trim END vim9script |