diff src/vim9script.c @ 21279:8d1d11afd8c8 v8.2.1190

patch 8.2.1190: Vim9: checking for Vim9 syntax is spread out Commit: https://github.com/vim/vim/commit/eb6880b6eb7c4631f6103575c0d1336b149348c1 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jul 12 17:07:05 2020 +0200 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().
author Bram Moolenaar <Bram@vim.org>
date Sun, 12 Jul 2020 17:15:03 +0200
parents 1f4d0375f947
children 66386ca8a69f
line wrap: on
line diff
--- a/src/vim9script.c
+++ b/src/vim9script.c
@@ -22,7 +22,9 @@ static char e_needs_vim9[] = N_("E1042: 
     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 @@ ex_vim9script(exarg_T *eap)
     void
 ex_export(exarg_T *eap)
 {
-    if (current_sctx.sc_version != SCRIPT_VERSION_VIM9)
+    if (!in_vim9script())
     {
 	emsg(_(e_needs_vim9));
 	return;