comparison src/vim9compile.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 c4e29355cd8b
children 27cb2e79ccde
comparison
equal deleted inserted replaced
25604:5ad1d3061d62 25605:6f13d9ea0d04
2260 isn->isn_arg.put.put_lnum = lnum; 2260 isn->isn_arg.put.put_lnum = lnum;
2261 return OK; 2261 return OK;
2262 } 2262 }
2263 2263
2264 static int 2264 static int
2265 generate_EXEC(cctx_T *cctx, char_u *line) 2265 generate_EXEC(cctx_T *cctx, isntype_T isntype, char_u *line)
2266 { 2266 {
2267 isn_T *isn; 2267 isn_T *isn;
2268 2268
2269 RETURN_OK_IF_SKIP(cctx); 2269 RETURN_OK_IF_SKIP(cctx);
2270 if ((isn = generate_instr(cctx, ISN_EXEC)) == NULL) 2270 if ((isn = generate_instr(cctx, isntype)) == NULL)
2271 return FAIL; 2271 return FAIL;
2272 isn->isn_arg.string = vim_strsave(line); 2272 isn->isn_arg.string = vim_strsave(line);
2273 return OK; 2273 return OK;
2274 } 2274 }
2275 2275
7424 int cc = *name_end; 7424 int cc = *name_end;
7425 char_u *p = lvp->ll_name; 7425 char_u *p = lvp->ll_name;
7426 int ret = OK; 7426 int ret = OK;
7427 size_t len; 7427 size_t len;
7428 char_u *buf; 7428 char_u *buf;
7429 isntype_T isn = ISN_EXEC;
7429 7430
7430 if (cctx->ctx_skip == SKIP_YES) 7431 if (cctx->ctx_skip == SKIP_YES)
7431 return OK; 7432 return OK;
7432 7433
7433 // Cannot use :lockvar and :unlockvar on local variables. 7434 // Cannot use :lockvar and :unlockvar on local variables.
7435 { 7436 {
7436 char_u *end = find_name_end(p, NULL, NULL, FNE_CHECK_START); 7437 char_u *end = find_name_end(p, NULL, NULL, FNE_CHECK_START);
7437 7438
7438 if (lookup_local(p, end - p, NULL, cctx) == OK) 7439 if (lookup_local(p, end - p, NULL, cctx) == OK)
7439 { 7440 {
7440 emsg(_(e_cannot_lock_unlock_local_variable)); 7441 char_u *s = p;
7441 return FAIL; 7442
7443 if (*end != '.' && *end != '[')
7444 {
7445 emsg(_(e_cannot_lock_unlock_local_variable));
7446 return FAIL;
7447 }
7448
7449 // For "d.member" put the local variable on the stack, it will be
7450 // passed to ex_lockvar() indirectly.
7451 if (compile_load(&s, end, cctx, FALSE, FALSE) == FAIL)
7452 return FAIL;
7453 isn = ISN_LOCKUNLOCK;
7442 } 7454 }
7443 } 7455 }
7444 7456
7445 // Checking is done at runtime. 7457 // Checking is done at runtime.
7446 *name_end = NUL; 7458 *name_end = NUL;
7451 else 7463 else
7452 { 7464 {
7453 vim_snprintf((char *)buf, len, "%s %s", 7465 vim_snprintf((char *)buf, len, "%s %s",
7454 eap->cmdidx == CMD_lockvar ? "lockvar" : "unlockvar", 7466 eap->cmdidx == CMD_lockvar ? "lockvar" : "unlockvar",
7455 p); 7467 p);
7456 ret = generate_EXEC(cctx, buf); 7468 ret = generate_EXEC(cctx, isn, buf);
7457 7469
7458 vim_free(buf); 7470 vim_free(buf);
7459 *name_end = cc; 7471 *name_end = cc;
7460 } 7472 }
7461 return ret; 7473 return ret;
9108 } 9120 }
9109 } 9121 }
9110 generate_EXECCONCAT(cctx, count); 9122 generate_EXECCONCAT(cctx, count);
9111 } 9123 }
9112 else 9124 else
9113 generate_EXEC(cctx, line); 9125 generate_EXEC(cctx, ISN_EXEC, line);
9114 9126
9115 theend: 9127 theend:
9116 if (*nextcmd != NUL) 9128 if (*nextcmd != NUL)
9117 { 9129 {
9118 // the parser expects a pointer to the bar, put it back 9130 // the parser expects a pointer to the bar, put it back
10196 case ISN_LOADENV: 10208 case ISN_LOADENV:
10197 case ISN_LOADG: 10209 case ISN_LOADG:
10198 case ISN_LOADOPT: 10210 case ISN_LOADOPT:
10199 case ISN_LOADT: 10211 case ISN_LOADT:
10200 case ISN_LOADW: 10212 case ISN_LOADW:
10213 case ISN_LOCKUNLOCK:
10201 case ISN_PUSHEXC: 10214 case ISN_PUSHEXC:
10202 case ISN_PUSHFUNC: 10215 case ISN_PUSHFUNC:
10203 case ISN_PUSHS: 10216 case ISN_PUSHS:
10204 case ISN_RANGE: 10217 case ISN_RANGE:
10205 case ISN_STOREAUTO: 10218 case ISN_STOREAUTO: