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

patch 8.2.2018: Vim9: script variable not found from lambda

Problem:    Vim9: script variable not found from lambda.
Solution:   In a lambda also check the script hashtab for a variable without a
            scope. (closes #7329)
This commit is contained in:
Bram Moolenaar
2020-11-19 21:47:56 +01:00
parent 67d1c68f09
commit 2ea95b61f4
3 changed files with 33 additions and 1 deletions

View File

@@ -2628,7 +2628,28 @@ find_var(char_u *name, hashtab_T **htp, int no_autoload)
return ret;
// Search in parent scope for lambda
return find_var_in_scoped_ht(name, no_autoload || htp != NULL);
ret = find_var_in_scoped_ht(name, no_autoload || htp != NULL);
if (ret != NULL)
return ret;
// in Vim9 script items without a scope can be script-local
if (in_vim9script() && name[0] != NUL && name[1] != ':')
{
ht = get_script_local_ht();
if (ht != NULL)
{
ret = find_var_in_ht(ht, *name, varname,
no_autoload || htp != NULL);
if (ret != NULL)
{
if (htp != NULL)
*htp = ht;
return ret;
}
}
}
return NULL;
}
/*