forked from aniani/vim
patch 9.0.0840: cannot change a slice of a const list
Problem: Cannot change a slice of a const list. (Takumi KAGIYAMA) Solution: Remove the const flag from the slice type. (closes #11490)
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user