0
0
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:
Bram Moolenaar
2022-01-26 21:01:15 +00:00
parent 1080c48ec8
commit 70c43d84be
9 changed files with 82 additions and 18 deletions

View File

@@ -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