patch 9.0.0460: loop variable can't be found
Problem: Loop variable can't be found.
Solution: Adjust block_id of the loop variable each round.
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 02cbb25..9755d97 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -183,6 +183,9 @@
if (cctx == NULL)
{
+ if (cstack == NULL)
+ return NULL;
+
// Not in a function scope, find variable with block ID equal to or
// smaller than the current block id. Use "cstack" to go up the block
// scopes.
@@ -220,6 +223,23 @@
}
/*
+ * If "name" can be found in the current script set it's "block_id".
+ */
+ void
+update_script_var_block_id(char_u *name, int block_id)
+{
+ scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid);
+ hashitem_T *hi;
+ sallvar_T *sav;
+
+ hi = hash_find(&si->sn_all_vars.dv_hashtab, name);
+ if (HASHITEM_EMPTY(hi))
+ return;
+ sav = HI2SAV(hi);
+ sav->sav_block_id = block_id;
+}
+
+/*
* Return TRUE if the script context is Vim9 script.
*/
int