comparison src/userfunc.c @ 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 fc0830246f49
comparison
equal deleted inserted replaced
30290:e5d24015e8c5 30291:61a688be1899
2450 /* 2450 /*
2451 * Copy already defined function "lambda" to a new function with name "global". 2451 * Copy already defined function "lambda" to a new function with name "global".
2452 * This is for when a compiled function defines a global function. 2452 * This is for when a compiled function defines a global function.
2453 */ 2453 */
2454 int 2454 int
2455 copy_func(char_u *lambda, char_u *global, ectx_T *ectx) 2455 copy_lambda_to_global_func(
2456 char_u *lambda,
2457 char_u *global,
2458 short loop_var_idx,
2459 short loop_var_count,
2460 ectx_T *ectx)
2456 { 2461 {
2457 ufunc_T *ufunc = find_func_even_dead(lambda, FFED_IS_GLOBAL); 2462 ufunc_T *ufunc = find_func_even_dead(lambda, FFED_IS_GLOBAL);
2458 ufunc_T *fp = NULL; 2463 ufunc_T *fp = NULL;
2459 2464
2460 if (ufunc == NULL) 2465 if (ufunc == NULL)
2517 { 2522 {
2518 partial_T *pt = ALLOC_CLEAR_ONE(partial_T); 2523 partial_T *pt = ALLOC_CLEAR_ONE(partial_T);
2519 2524
2520 if (pt == NULL) 2525 if (pt == NULL)
2521 goto failed; 2526 goto failed;
2522 if (fill_partial_and_closure(pt, ufunc, ectx) == FAIL) 2527 if (fill_partial_and_closure(pt, ufunc, loop_var_idx, loop_var_count,
2528 ectx) == FAIL)
2523 { 2529 {
2524 vim_free(pt); 2530 vim_free(pt);
2525 goto failed; 2531 goto failed;
2526 } 2532 }
2527 ufunc->uf_partial = pt; 2533 ufunc->uf_partial = pt;