comparison src/ex_eval.c @ 26236:9e6ddd7b91cd v8.2.3649

patch 8.2.3649: Vim9: error for variable declared in while loop Commit: https://github.com/vim/vim/commit/7a53f29c031f54ab67a803e5e3f8cb44e4edc4bc Author: Bram Moolenaar <Bram@vim.org> Date: Mon Nov 22 18:31:02 2021 +0000 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 https://github.com/vim/vim/issues/9191)
author Bram Moolenaar <Bram@vim.org>
date Mon, 22 Nov 2021 19:45:03 +0100
parents 269ecc6d69bc
children 3711e56f7e7b
comparison
equal deleted inserted replaced
26235:f06e596b22f6 26236:9e6ddd7b91cd
1199 int i; 1199 int i;
1200 int func_defined = cstack->cs_flags[cstack->cs_idx] 1200 int func_defined = cstack->cs_flags[cstack->cs_idx]
1201 & CSF_FUNC_DEF; 1201 & CSF_FUNC_DEF;
1202 1202
1203 // Any variables defined in the previous round are no longer 1203 // Any variables defined in the previous round are no longer
1204 // visible. Keep the first one, it is the loop variable that 1204 // visible. Keep the first one for ":for", it is the loop
1205 // we reuse every time around. 1205 // variable that we reuse every time around.
1206 for (i = cstack->cs_script_var_len[cstack->cs_idx] + 1; 1206 for (i = cstack->cs_script_var_len[cstack->cs_idx]
1207 + (eap->cmdidx == CMD_while ? 0 : 1);
1207 i < si->sn_var_vals.ga_len; ++i) 1208 i < si->sn_var_vals.ga_len; ++i)
1208 { 1209 {
1209 svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data) + i; 1210 svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data) + i;
1210 1211
1211 // sv_name is set to NULL if it was already removed. This 1212 // sv_name is set to NULL if it was already removed. This