mirror of
https://github.com/vim/vim.git
synced 2025-10-28 09:27:14 -04:00
patch 8.2.4225: Vim9: depth argument of :lockvar not parsed in :def function
Problem: Vim9: depth argument of :lockvar not parsed in :def function. Solution: Parse the optional depth argument. (closes #9629) Fix that locking doesn't work for a non-materialize list.
This commit is contained in:
@@ -1396,6 +1396,35 @@ def Test_lockvar()
|
||||
lockvar whatever
|
||||
endif
|
||||
|
||||
g:lockme = [1, 2, 3]
|
||||
lockvar 1 g:lockme
|
||||
g:lockme[1] = 77
|
||||
assert_equal([1, 77, 3], g:lockme)
|
||||
|
||||
lockvar 2 g:lockme
|
||||
var caught = false
|
||||
try
|
||||
g:lockme[1] = 99
|
||||
catch /E1119:/
|
||||
caught = true
|
||||
endtry
|
||||
assert_true(caught)
|
||||
assert_equal([1, 77, 3], g:lockme)
|
||||
unlet g:lockme
|
||||
|
||||
# also for non-materialized list
|
||||
g:therange = range(3)
|
||||
lockvar 2 g:therange
|
||||
caught = false
|
||||
try
|
||||
g:therange[1] = 99
|
||||
catch /E1119:/
|
||||
caught = true
|
||||
endtry
|
||||
assert_true(caught)
|
||||
assert_equal([0, 1, 2], g:therange)
|
||||
unlet g:therange
|
||||
|
||||
var d = {a: 1, b: 2}
|
||||
d.a = 3
|
||||
d.b = 4
|
||||
|
||||
Reference in New Issue
Block a user