1
0
forked from aniani/vim

patch 8.2.3339: Vim9: cannot lock a member in a local dict

Problem:    Vim9: cannot lock a member in a local dict.
Solution:   Get the local dict from the stack and pass it to get_lval().
This commit is contained in:
Bram Moolenaar
2021-08-13 19:40:51 +02:00
parent 89071cb6a1
commit aacc966c5d
8 changed files with 122 additions and 32 deletions

View File

@@ -1396,6 +1396,27 @@ fill_partial_and_closure(partial_T *pt, ufunc_T *ufunc, ectx_T *ectx)
return OK;
}
/*
* Execute iptr->isn_arg.string as an Ex command.
*/
static int
exec_command(isn_T *iptr)
{
source_cookie_T cookie;
SOURCING_LNUM = iptr->isn_lnum;
// Pass getsourceline to get an error for a missing ":end"
// command.
CLEAR_FIELD(cookie);
cookie.sourcing_lnum = iptr->isn_lnum - 1;
if (do_cmdline(iptr->isn_arg.string,
getsourceline, &cookie,
DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_KEYTYPED) == FAIL
|| did_emsg)
return FAIL;
return OK;
}
// used for v_instr of typval of VAR_INSTR
struct instr_S {
ectx_T *instr_ectx;
@@ -1637,21 +1658,8 @@ exec_instructions(ectx_T *ectx)
{
// execute Ex command line
case ISN_EXEC:
{
source_cookie_T cookie;
SOURCING_LNUM = iptr->isn_lnum;
// Pass getsourceline to get an error for a missing ":end"
// command.
CLEAR_FIELD(cookie);
cookie.sourcing_lnum = iptr->isn_lnum - 1;
if (do_cmdline(iptr->isn_arg.string,
getsourceline, &cookie,
DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_KEYTYPED)
== FAIL
|| did_emsg)
goto on_error;
}
if (exec_command(iptr) == FAIL)
goto on_error;
break;
// execute Ex command line split at NL characters.
@@ -2880,6 +2888,23 @@ exec_instructions(ectx_T *ectx)
vim_unsetenv(iptr->isn_arg.unlet.ul_name);
break;
case ISN_LOCKUNLOCK:
{
typval_T *lval_root_save = lval_root;
int res;
// Stack has the local variable, argument the whole :lock
// or :unlock command, like ISN_EXEC.
--ectx->ec_stack.ga_len;
lval_root = STACK_TV_BOT(0);
res = exec_command(iptr);
clear_tv(lval_root);
lval_root = lval_root_save;
if (res == FAIL)
goto on_error;
}
break;
case ISN_LOCKCONST:
item_lock(STACK_TV_BOT(-1), 100, TRUE, TRUE);
break;
@@ -5244,6 +5269,9 @@ list_instructions(char *pfx, isn_T *instr, int instr_count, ufunc_T *ufunc)
case ISN_UNLETRANGE:
smsg("%s%4d UNLETRANGE", pfx, current);
break;
case ISN_LOCKUNLOCK:
smsg("%s%4d LOCKUNLOCK %s", pfx, current, iptr->isn_arg.string);
break;
case ISN_LOCKCONST:
smsg("%s%4d LOCKCONST", pfx, current);
break;