patch 9.1.1614: Vim9: possible variable type change

Problem:  Vim9: possible variable type change when using closure in a
          for loop (Maxim Kim)
Solution: Use unwind_locals(..., TRUE) (Yegappan Lakshmanan)

fixes: #17844
closes: #17951

Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Yegappan Lakshmanan
2025-08-09 23:52:07 +02:00
committed by Christian Brabandt
parent a2bb21a895
commit f56f490ca2
5 changed files with 101 additions and 3 deletions

View File

@ -1252,7 +1252,7 @@ compile_endfor(char_u *arg, cctx_T *cctx)
if (compile_loop_end(&forscope->fs_loop_info, cctx) == FAIL)
return NULL;
unwind_locals(cctx, scope->se_local_count, FALSE);
unwind_locals(cctx, scope->se_local_count, TRUE);
// At end of ":for" scope jump back to the FOR instruction.
generate_JUMP(cctx, JUMP_ALWAYS, forscope->fs_top_label);
@ -1379,7 +1379,7 @@ compile_endwhile(char_u *arg, cctx_T *cctx)
if (compile_loop_end(&whilescope->ws_loop_info, cctx) == FAIL)
return NULL;
unwind_locals(cctx, scope->se_local_count, FALSE);
unwind_locals(cctx, scope->se_local_count, TRUE);
#ifdef FEAT_PROFILE
// count the endwhile before jumping