patch 8.2.1190: Vim9: checking for Vim9 syntax is spread out
Problem: Vim9: checking for Vim9 syntax is spread out.
Solution: Use in_vim9script().
diff --git a/src/vim9script.c b/src/vim9script.c
index c191113..3c57d34 100644
--- a/src/vim9script.c
+++ b/src/vim9script.c
@@ -22,7 +22,9 @@
int
in_vim9script(void)
{
- // TODO: go up the stack?
+ // Do not go up the stack, a ":function" inside vim9script uses legacy
+ // syntax. "sc_version" is also set when compiling a ":def" function in
+ // legacy script.
return current_sctx.sc_version == SCRIPT_VERSION_VIM9;
}
@@ -67,7 +69,7 @@
void
ex_export(exarg_T *eap)
{
- if (current_sctx.sc_version != SCRIPT_VERSION_VIM9)
+ if (!in_vim9script())
{
emsg(_(e_needs_vim9));
return;