Mercurial > vim
comparison src/eval.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 | 54fef15ed370 |
comparison
equal
deleted
inserted
replaced
25604:5ad1d3061d62 | 25605:6f13d9ea0d04 |
---|---|
900 | 900 |
901 // Without [idx] or .key we are done. | 901 // Without [idx] or .key we are done. |
902 if ((*p != '[' && *p != '.') || lp->ll_name == NULL) | 902 if ((*p != '[' && *p != '.') || lp->ll_name == NULL) |
903 return p; | 903 return p; |
904 | 904 |
905 cc = *p; | 905 if (in_vim9script() && lval_root != NULL) |
906 *p = NUL; | 906 { |
907 // When we would write to the variable pass &ht and prevent autoload. | 907 // using local variable |
908 writing = !(flags & GLV_READ_ONLY); | 908 lp->ll_tv = lval_root; |
909 v = find_var(lp->ll_name, writing ? &ht : NULL, | 909 } |
910 else | |
911 { | |
912 cc = *p; | |
913 *p = NUL; | |
914 // When we would write to the variable pass &ht and prevent autoload. | |
915 writing = !(flags & GLV_READ_ONLY); | |
916 v = find_var(lp->ll_name, writing ? &ht : NULL, | |
910 (flags & GLV_NO_AUTOLOAD) || writing); | 917 (flags & GLV_NO_AUTOLOAD) || writing); |
911 if (v == NULL && !quiet) | 918 if (v == NULL && !quiet) |
912 semsg(_(e_undefined_variable_str), lp->ll_name); | 919 semsg(_(e_undefined_variable_str), lp->ll_name); |
913 *p = cc; | 920 *p = cc; |
914 if (v == NULL) | 921 if (v == NULL) |
915 return NULL; | 922 return NULL; |
923 lp->ll_tv = &v->di_tv; | |
924 } | |
916 | 925 |
917 if (in_vim9script() && (flags & GLV_NO_DECL) == 0) | 926 if (in_vim9script() && (flags & GLV_NO_DECL) == 0) |
918 { | 927 { |
919 if (!quiet) | 928 if (!quiet) |
920 semsg(_(e_variable_already_declared), lp->ll_name); | 929 semsg(_(e_variable_already_declared), lp->ll_name); |
922 } | 931 } |
923 | 932 |
924 /* | 933 /* |
925 * Loop until no more [idx] or .key is following. | 934 * Loop until no more [idx] or .key is following. |
926 */ | 935 */ |
927 lp->ll_tv = &v->di_tv; | |
928 var1.v_type = VAR_UNKNOWN; | 936 var1.v_type = VAR_UNKNOWN; |
929 var2.v_type = VAR_UNKNOWN; | 937 var2.v_type = VAR_UNKNOWN; |
930 while (*p == '[' || (*p == '.' && p[1] != '=' && p[1] != '.')) | 938 while (*p == '[' || (*p == '.' && p[1] != '=' && p[1] != '.')) |
931 { | 939 { |
932 if (*p == '.' && lp->ll_tv->v_type != VAR_DICT) | 940 if (*p == '.' && lp->ll_tv->v_type != VAR_DICT) |