0
0
mirror of https://github.com/vim/vim.git synced 2025-10-05 05:34:07 -04:00

patch 8.2.2672: Vim9: cannot use :lockvar and :unlockvar in compiled script

Problem:    Vim9: cannot use :lockvar and :unlockvar in compiled script.
Solution:   Implement locking support.
This commit is contained in:
Bram Moolenaar
2021-03-28 20:38:34 +02:00
parent f6bdd82c7e
commit b2cb6c8bbd
4 changed files with 97 additions and 10 deletions

View File

@@ -1135,4 +1135,42 @@ def Test_windo_missing_endif()
CheckDefExecFailure(lines, 'E171:', 1)
enddef
let s:theList = [1, 2, 3]
def Test_lockvar()
s:theList[1] = 22
assert_equal([1, 22, 3], s:theList)
lockvar s:theList
assert_fails('theList[1] = 77', 'E741:')
unlockvar s:theList
s:theList[1] = 44
assert_equal([1, 44, 3], s:theList)
var lines =<< trim END
vim9script
var theList = [1, 2, 3]
def SetList()
theList[1] = 22
assert_equal([1, 22, 3], theList)
lockvar theList
theList[1] = 77
enddef
SetList()
END
CheckScriptFailure(lines, 'E1119', 4)
lines =<< trim END
var theList = [1, 2, 3]
lockvar theList
END
CheckDefFailure(lines, 'E1178', 2)
lines =<< trim END
var theList = [1, 2, 3]
unlockvar theList
END
CheckDefFailure(lines, 'E1178', 2)
enddef
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker