0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 9.0.0502: a closure in a nested loop in a :def function does not work

Problem:    A closure in a nested loop in a :def function does not work.
Solution:   Use an array of loopvars, one per loop level.
This commit is contained in:
Bram Moolenaar
2022-09-19 15:54:34 +01:00
parent 18ee0feb5d
commit cc34181f99
15 changed files with 398 additions and 182 deletions

View File

@@ -4807,11 +4807,12 @@ partial_free(partial_T *pt)
funcstack_check_refcount(pt->pt_funcstack);
}
// Similarly for loop variables.
if (pt->pt_loopvars != NULL)
{
--pt->pt_loopvars->lvs_refcount;
loopvars_check_refcount(pt->pt_loopvars);
}
for (i = 0; i < MAX_LOOP_DEPTH; ++i)
if (pt->pt_loopvars[i] != NULL)
{
--pt->pt_loopvars[i]->lvs_refcount;
loopvars_check_refcount(pt->pt_loopvars[i]);
}
vim_free(pt);
}
@@ -4839,8 +4840,15 @@ partial_unref(partial_T *pt)
if (pt->pt_funcstack != NULL)
done = funcstack_check_refcount(pt->pt_funcstack);
if (!done && pt->pt_loopvars != NULL)
loopvars_check_refcount(pt->pt_loopvars);
if (!done)
{
int depth;
for (depth = 0; depth < MAX_LOOP_DEPTH; ++depth)
if (pt->pt_loopvars[depth] != NULL
&& loopvars_check_refcount(pt->pt_loopvars[depth]))
break;
}
}
}
}