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.
diff --git a/src/testdir/test_vim9_cmd.vim b/src/testdir/test_vim9_cmd.vim
index 6347a28..7b2edfd 100644
--- a/src/testdir/test_vim9_cmd.vim
+++ b/src/testdir/test_vim9_cmd.vim
@@ -1396,6 +1396,35 @@
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