summaryrefslogtreecommitdiffstats
path: root/src/ex_eval.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-10-15 12:46:44 +0200
committerBram Moolenaar <Bram@vim.org>2020-10-15 12:46:44 +0200
commitfbbcd00367e1a4fafd047d42ffce0e5dce88925c (patch)
tree93f997f2b6fad6457ff728399b8be9da35ad1ead /src/ex_eval.c
parent8d739de43b84ef7817b3b5b826d1cbfe7572a62a (diff)
patch 8.2.1846: Vim9: block variables are not found in compiled functionv8.2.1846
Problem: Vim9: variables declared in a local block are not found in when a function is compiled. Solution: Look for script variables in sn_all_vars.
Diffstat (limited to 'src/ex_eval.c')
-rw-r--r--src/ex_eval.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/ex_eval.c b/src/ex_eval.c
index baf5de3419..22e83ae34c 100644
--- a/src/ex_eval.c
+++ b/src/ex_eval.c
@@ -918,7 +918,8 @@ enter_block(cstack_T *cstack)
scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid);
cstack->cs_script_var_len[cstack->cs_idx] = si->sn_var_vals.ga_len;
- cstack->cs_block_id[cstack->cs_idx] = ++si->sn_current_block_id;
+ cstack->cs_block_id[cstack->cs_idx] = ++si->sn_last_block_id;
+ si->sn_current_block_id = si->sn_last_block_id;
}
}
@@ -938,11 +939,16 @@ leave_block(cstack_T *cstack)
if (sv->sv_name != NULL)
// Remove a variable declared inside the block, if it still
// exists, from sn_vars and move the value into sn_all_vars.
- hide_script_var(si, sv);
+ hide_script_var(si, i);
}
// TODO: is this needed?
cstack->cs_script_var_len[cstack->cs_idx] = si->sn_var_vals.ga_len;
+
+ if (cstack->cs_idx == 0)
+ si->sn_current_block_id = 0;
+ else
+ si->sn_current_block_id = cstack->cs_block_id[cstack->cs_idx - 1];
}
--cstack->cs_idx;
}