diff src/ex_eval.c @ 26051:1c567eb92222 v8.2.3559

patch 8.2.3559: loop variable recreated every time Commit: https://github.com/vim/vim/commit/ee56f3f119c4378a5b62b4d504cff3373b363308 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Oct 23 12:34:27 2021 +0100 patch 8.2.3559: loop variable recreated every time Problem: Loop variable recreated every time. Solution: Keep the loop variable when looping.
author Bram Moolenaar <Bram@vim.org>
date Sat, 23 Oct 2021 13:45:04 +0200
parents 892f937358ea
children 269ecc6d69bc
line wrap: on
line diff
--- a/src/ex_eval.c
+++ b/src/ex_eval.c
@@ -1191,8 +1191,9 @@ ex_while(exarg_T *eap)
 								& CSF_FUNC_DEF;
 
 		// Any variables defined in the previous round are no longer
-		// visible.
-		for (i = cstack->cs_script_var_len[cstack->cs_idx];
+		// 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;
 					       i < si->sn_var_vals.ga_len; ++i)
 		{
 		    svar_T	*sv = ((svar_T *)si->sn_var_vals.ga_data) + i;