Skip to content

Commit

Permalink
patch 8.2.4227: Vim9: using "lockvar!" in :def function does not work
Browse files Browse the repository at this point in the history
Problem:    Vim9: using "lockvar!" in :def function does not work.
Solution:   Add "!" instead of "-1". (closes #9634)
  • Loading branch information
brammool committed Jan 26, 2022
1 parent fc4c448 commit e939f5e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
11 changes: 11 additions & 0 deletions src/testdir/test_vim9_cmd.vim
Original file line number Diff line number Diff line change
Expand Up @@ -1425,6 +1425,17 @@ def Test_lockvar()
assert_equal([0, 1, 2], 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}
d.a = 3
d.b = 4
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
4227,
/**/
4226,
/**/
Expand Down
10 changes: 6 additions & 4 deletions src/vim9cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,12 @@ compile_lock_unlock(
ret = FAIL;
else
{
vim_snprintf((char *)buf, len, "%s %d %s",
eap->cmdidx == CMD_lockvar ? "lockvar" : "unlockvar",
deep,
p);
char *cmd = eap->cmdidx == CMD_lockvar ? "lockvar" : "unlockvar";

if (deep < 0)
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);

vim_free(buf);
Expand Down

0 comments on commit e939f5e

Please sign in to comment.