Mercurial > vim
diff src/vim9execute.c @ 25605:6f13d9ea0d04 v8.2.3339
patch 8.2.3339: Vim9: cannot lock a member in a local dict
Commit: https://github.com/vim/vim/commit/aacc966c5d0ed91e33ed32b08f17cf4df3ca1394
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Aug 13 19:40:51 2021 +0200
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().
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 13 Aug 2021 19:45:03 +0200 |
parents | ea69398b40d1 |
children | f8bcd21e6e24 |
line wrap: on
line diff
--- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -1396,6 +1396,27 @@ fill_partial_and_closure(partial_T *pt, 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 *inst 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;