summaryrefslogtreecommitdiff
path: root/src/evalvars.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-11-19 21:47:56 +0100
committerBram Moolenaar <Bram@vim.org>2020-11-19 21:47:56 +0100
commit2ea95b61f4bec9b71cf916eebe8d11abc76617a0 (patch)
tree0bf9914214c629f0dfb7e749c931e0cc2159f8d4 /src/evalvars.c
parent67d1c68f095eb6cbb6355b04972e384d23065c2c (diff)
downloadvim-git-2ea95b61f4bec9b71cf916eebe8d11abc76617a0.tar.gz
patch 8.2.2018: Vim9: script variable not found from lambdav8.2.2018
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)
Diffstat (limited to 'src/evalvars.c')
-rw-r--r--src/evalvars.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/evalvars.c b/src/evalvars.c
index 9c05c57a0..75893bb27 100644
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -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;
}
/*