0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

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.
This commit is contained in:
Bram Moolenaar
2022-09-14 00:30:51 +01:00
parent 353b68a991
commit 766ae5b252
11 changed files with 86 additions and 25 deletions

View File

@@ -183,6 +183,9 @@ find_script_var(char_u *name, size_t len, cctx_T *cctx, cstack_T *cstack)
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.
@@ -219,6 +222,23 @@ find_script_var(char_u *name, size_t len, cctx_T *cctx, cstack_T *cstack)
return NULL;
}
/*
* 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.
*/