1
0
forked from aniani/vim

patch 8.2.4227: Vim9: using "lockvar!" in :def function does not work

Problem:    Vim9: using "lockvar!" in :def function does not work.
Solution:   Add "!" instead of "-1". (closes #9634)
This commit is contained in:
Bram Moolenaar 2022-01-26 21:32:59 +00:00
parent fc4c44836a
commit e939f5ebba
3 changed files with 19 additions and 4 deletions

View File

@ -1425,6 +1425,17 @@ def Test_lockvar()
assert_equal([0, 1, 2], g:therange) assert_equal([0, 1, 2], g:therange)
unlet g:therange unlet g:therange
# use exclamation mark for locking deeper
g:nestedlist = [1, [2, 3], 4]
lockvar! g:nestedlist
try
g:nestedlist[1][0] = 9
catch /E1119:/
caught = true
endtry
assert_true(caught)
unlet g:nestedlist
var d = {a: 1, b: 2} var d = {a: 1, b: 2}
d.a = 3 d.a = 3
d.b = 4 d.b = 4

View File

@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
4227,
/**/ /**/
4226, 4226,
/**/ /**/

View File

@ -223,10 +223,12 @@ compile_lock_unlock(
ret = FAIL; ret = FAIL;
else else
{ {
vim_snprintf((char *)buf, len, "%s %d %s", char *cmd = eap->cmdidx == CMD_lockvar ? "lockvar" : "unlockvar";
eap->cmdidx == CMD_lockvar ? "lockvar" : "unlockvar",
deep, if (deep < 0)
p); vim_snprintf((char *)buf, len, "%s! %s", cmd, p);
else
vim_snprintf((char *)buf, len, "%s %d %s", cmd, deep, p);
ret = generate_EXEC_copy(cctx, isn, buf); ret = generate_EXEC_copy(cctx, isn, buf);
vim_free(buf); vim_free(buf);