0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

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.
This commit is contained in:
Bram Moolenaar
2022-09-16 19:04:24 +01:00
parent abd58d8aee
commit 8fa745e7be
13 changed files with 285 additions and 77 deletions

View File

@@ -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