comparison 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
comparison
equal deleted inserted replaced
21278:acefabf736a3 21279:8d1d11afd8c8
20 static char e_needs_vim9[] = N_("E1042: export can only be used in vim9script"); 20 static char e_needs_vim9[] = N_("E1042: export can only be used in vim9script");
21 21
22 int 22 int
23 in_vim9script(void) 23 in_vim9script(void)
24 { 24 {
25 // TODO: go up the stack? 25 // Do not go up the stack, a ":function" inside vim9script uses legacy
26 // syntax. "sc_version" is also set when compiling a ":def" function in
27 // legacy script.
26 return current_sctx.sc_version == SCRIPT_VERSION_VIM9; 28 return current_sctx.sc_version == SCRIPT_VERSION_VIM9;
27 } 29 }
28 30
29 /* 31 /*
30 * ":vim9script". 32 * ":vim9script".
65 * ":export {Name, ...}" 67 * ":export {Name, ...}"
66 */ 68 */
67 void 69 void
68 ex_export(exarg_T *eap) 70 ex_export(exarg_T *eap)
69 { 71 {
70 if (current_sctx.sc_version != SCRIPT_VERSION_VIM9) 72 if (!in_vim9script())
71 { 73 {
72 emsg(_(e_needs_vim9)); 74 emsg(_(e_needs_vim9));
73 return; 75 return;
74 } 76 }
75 77