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)
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;
}
/*
Line_continuation_in_def('.')->assert_equal('full')
enddef
+def Test_script_var_in_lambda()
+ var lines =<< trim END
+ vim9script
+ var script = 'test'
+ assert_equal(['test'], map(['one'], {-> script}))
+ END
+ CheckScriptSuccess(lines)
+enddef
+
def Line_continuation_in_lambda(): list<string>
var x = range(97, 100)
->map({_, v -> nr2char(v)
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 2018,
/**/
2017,
/**/