diff src/vim9.h @ 30297:bee38b1d323c v9.0.0484

patch 9.0.0484: in :def function all closures in loop get the same variables Commit: https://github.com/vim/vim/commit/8abb584ab85d5855d810d1c6e2b260f45ec839b7 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Sep 17 12:39:58 2022 +0100 patch 9.0.0484: in :def function all closures in loop get the same variables Problem: In a :def function all closures in a loop get the same variables. Solution: Add ENDLOOP at break, continue and return if needed.
author Bram Moolenaar <Bram@vim.org>
date Sat, 17 Sep 2022 13:45:03 +0200
parents 61a688be1899
children 029c59bf78f1
line wrap: on
line diff
--- a/src/vim9.h
+++ b/src/vim9.h
@@ -625,15 +625,20 @@ typedef struct {
     endlabel_T	*is_end_label;	    // instructions to set end label
 } ifscope_T;
 
+// info used by :for and :while needed for ENDLOOP
+typedef struct {
+    int	    li_local_count;	    // ctx_locals.ga_len at loop start
+    int	    li_closure_count;	    // ctx_closure_count at loop start
+    int	    li_funcref_idx;	    // index of var that holds funcref count
+} loop_info_T;
+
 /*
  * info specific for the scope of :while
  */
 typedef struct {
     int		ws_top_label;	    // instruction idx at WHILE
     endlabel_T	*ws_end_label;	    // instructions to set end
-    int		ws_funcref_idx;	    // index of var that holds funcref count
-    int		ws_local_count;	    // ctx_locals.ga_len at :while
-    int		ws_closure_count;   // ctx_closure_count at :while
+    loop_info_T ws_loop_info;	    // info for LOOPEND
 } whilescope_T;
 
 /*
@@ -642,9 +647,7 @@ typedef struct {
 typedef struct {
     int		fs_top_label;	    // instruction idx at FOR
     endlabel_T	*fs_end_label;	    // break instructions
-    int		fs_funcref_idx;	    // index of var that holds funcref count
-    int		fs_local_count;	    // ctx_locals.ga_len at :for
-    int		fs_closure_count;   // ctx_closure_count at :for
+    loop_info_T	fs_loop_info;	    // info for LOOPEND
 } forscope_T;
 
 /*