0
0
mirror of https://github.com/vim/vim.git synced 2025-09-27 04:14:06 -04:00

patch 8.2.3649: Vim9: error for variable declared in while loop

Problem:    Vim9: error for variable declared in while loop.
Solution:   Do not keep the first variable. (closes #9191)
This commit is contained in:
Bram Moolenaar
2021-11-22 18:31:02 +00:00
parent 4671e88d7d
commit 7a53f29c03
3 changed files with 21 additions and 3 deletions

View File

@@ -1201,9 +1201,10 @@ ex_while(exarg_T *eap)
& CSF_FUNC_DEF;
// Any variables defined in the previous round are no longer
// visible. Keep the first one, it is the loop variable that
// we reuse every time around.
for (i = cstack->cs_script_var_len[cstack->cs_idx] + 1;
// visible. Keep the first one for ":for", it is the loop
// variable that we reuse every time around.
for (i = cstack->cs_script_var_len[cstack->cs_idx]
+ (eap->cmdidx == CMD_while ? 0 : 1);
i < si->sn_var_vals.ga_len; ++i)
{
svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data) + i;