Mercurial > vim
diff src/structs.h @ 30291:61a688be1899 v9.0.0481
patch 9.0.0481: in :def function all closures in loop get the same variables
Commit: https://github.com/vim/vim/commit/8fa745e7be3a791ac25f93ef0227bbc48ade8a37
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Sep 16 19:04:24 2022 +0100
patch 9.0.0481: 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: Use a separate list of variables for LOADOUTER and STOREOUTER.
Not copied at end of loop yet.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 16 Sep 2022 20:15:03 +0200 |
parents | d3cfd12839ef |
children | 5c181bb6c855 |
line wrap: on
line diff
--- a/src/structs.h +++ b/src/structs.h @@ -1656,7 +1656,7 @@ typedef enum { /* * Structure to hold info for a user function. - * When adding a field check copy_func(). + * When adding a field check copy_lambda_to_global_func(). */ typedef struct { @@ -1741,7 +1741,8 @@ typedef struct #define FC_NOARGS 0x200 // no a: variables in lambda #define FC_VIM9 0x400 // defined in vim9 script file #define FC_CFUNC 0x800 // defined as Lua C func -#define FC_COPY 0x1000 // copy of another function by copy_func() +#define FC_COPY 0x1000 // copy of another function by + // copy_lambda_to_global_func() #define FC_LAMBDA 0x2000 // one line "return {expr}" #define MAX_FUNC_ARGS 20 // maximum number of function arguments @@ -2096,10 +2097,17 @@ struct funcstack_S typedef struct outer_S outer_T; struct outer_S { - garray_T *out_stack; // stack from outer scope + garray_T *out_stack; // stack from outer scope, or a copy + // containing only arguments and local vars int out_frame_idx; // index of stack frame in out_stack outer_T *out_up; // outer scope of outer scope or NULL partial_T *out_up_partial; // partial owning out_up or NULL + + garray_T *out_loop_stack; // stack from outer scope, or a copy + // containing only vars inside the loop + short out_loop_var_idx; // first variable defined in a loop + // in out_loop_stack + short out_loop_var_count; // number of variables defined in a loop }; struct partial_S