diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-10-15 00:18:37 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-10-15 00:18:37 +0100 |
commit | a06758dd38851f022d270dd5102efbe1049d4712 (patch) | |
tree | 511901fac2db712627e0e6335a124d575afc95e3 | |
parent | 0a7984af5601323fae7b3398f05a48087db7b767 (diff) | |
download | vim-git-a06758dd38851f022d270dd5102efbe1049d4712.tar.gz |
patch 8.2.3511: Vim9: entry for loop variable is created every roundv8.2.3511
Problem: Vim9: entry for loop variable is created every round.
Solution: Only create the entry once. (closes #8996)
-rw-r--r-- | src/evalvars.c | 5 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9script.c | 5 |
3 files changed, 8 insertions, 4 deletions
diff --git a/src/evalvars.c b/src/evalvars.c index 4cc0fa8e3..fbf2d68d1 100644 --- a/src/evalvars.c +++ b/src/evalvars.c @@ -3319,7 +3319,7 @@ set_var_const( goto failed; } - if (var_in_vim9script) + if (var_in_vim9script && (flags & ASSIGN_FOR_LOOP) == 0) { where_T where = WHERE_INIT; @@ -3331,7 +3331,8 @@ set_var_const( goto failed; } - if (var_check_permission(di, name) == FAIL) + if ((flags & ASSIGN_FOR_LOOP) == 0 + && var_check_permission(di, name) == FAIL) goto failed; } else diff --git a/src/version.c b/src/version.c index d1f079cb2..f4e9f9f92 100644 --- a/src/version.c +++ b/src/version.c @@ -758,6 +758,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3511, +/**/ 3510, /**/ 3509, diff --git a/src/vim9script.c b/src/vim9script.c index ca245b255..9696dfe81 100644 --- a/src/vim9script.c +++ b/src/vim9script.c @@ -978,8 +978,9 @@ find_typval_in_script(typval_T *dest) // legacy script doesn't store variable types return NULL; - // Find the svar_T in sn_var_vals. - for (idx = 0; idx < si->sn_var_vals.ga_len; ++idx) + // Find the svar_T in sn_var_vals. Start at the end, in a for loop the + // variable was added at the end. + for (idx = si->sn_var_vals.ga_len - 1; idx >= 0; --idx) { svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data) + idx; |