diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-08-13 19:40:51 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-08-13 19:40:51 +0200 |
commit | aacc966c5d0ed91e33ed32b08f17cf4df3ca1394 (patch) | |
tree | e4cc65bc97301d078e9cada2f3bf025a7fff049e /src/eval.c | |
parent | 89071cb6a116a74f78f77a1853e6fada44872a15 (diff) |
patch 8.2.3339: Vim9: cannot lock a member in a local dictv8.2.3339
Problem: Vim9: cannot lock a member in a local dict.
Solution: Get the local dict from the stack and pass it to get_lval().
Diffstat (limited to 'src/eval.c')
-rw-r--r-- | src/eval.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/eval.c b/src/eval.c index edef8785d5..0dd2058872 100644 --- a/src/eval.c +++ b/src/eval.c @@ -902,17 +902,26 @@ get_lval( if ((*p != '[' && *p != '.') || lp->ll_name == NULL) return p; - cc = *p; - *p = NUL; - // When we would write to the variable pass &ht and prevent autoload. - writing = !(flags & GLV_READ_ONLY); - v = find_var(lp->ll_name, writing ? &ht : NULL, + if (in_vim9script() && lval_root != NULL) + { + // using local variable + lp->ll_tv = lval_root; + } + else + { + cc = *p; + *p = NUL; + // When we would write to the variable pass &ht and prevent autoload. + writing = !(flags & GLV_READ_ONLY); + v = find_var(lp->ll_name, writing ? &ht : NULL, (flags & GLV_NO_AUTOLOAD) || writing); - if (v == NULL && !quiet) - semsg(_(e_undefined_variable_str), lp->ll_name); - *p = cc; - if (v == NULL) - return NULL; + if (v == NULL && !quiet) + semsg(_(e_undefined_variable_str), lp->ll_name); + *p = cc; + if (v == NULL) + return NULL; + lp->ll_tv = &v->di_tv; + } if (in_vim9script() && (flags & GLV_NO_DECL) == 0) { @@ -924,7 +933,6 @@ get_lval( /* * Loop until no more [idx] or .key is following. */ - lp->ll_tv = &v->di_tv; var1.v_type = VAR_UNKNOWN; var2.v_type = VAR_UNKNOWN; while (*p == '[' || (*p == '.' && p[1] != '=' && p[1] != '.')) |