patch 9.0.0724: closure in compiled function gets same variable in block
Problem: Closure in compiled function gets same variable in block.
Solution: At the end of a block to not always reset the variable count.
(issue #11094)
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 468c384..b3e1b83 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -47,7 +47,8 @@
for (idx = 0; idx < cctx->ctx_locals.ga_len; ++idx)
{
lvp = ((lvar_T *)cctx->ctx_locals.ga_data) + idx;
- if (STRNCMP(name, lvp->lv_name, len) == 0
+ if (lvp->lv_name != NULL
+ && STRNCMP(name, lvp->lv_name, len) == 0
&& STRLEN(lvp->lv_name) == len)
{
if (lvar != NULL)