comparison src/vim9script.c @ 20816:9faab49c880f v8.2.0960

patch 8.2.0960: cannot use :import in legacy Vim script Commit: https://github.com/vim/vim/commit/9721fb4ea3db2559aaf7f71458da8ddda30ff93e Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jun 11 23:10:46 2020 +0200 patch 8.2.0960: cannot use :import in legacy Vim script Problem: Cannot use :import in legacy Vim script. Solution: Support :import in any Vim script.
author Bram Moolenaar <Bram@vim.org>
date Thu, 11 Jun 2020 23:15:03 +0200
parents 489cb75c76b6
children 0600ab7b9f09
comparison
equal deleted inserted replaced
20815:1b780bd39c59 20816:9faab49c880f
15 15
16 #if defined(FEAT_EVAL) || defined(PROTO) 16 #if defined(FEAT_EVAL) || defined(PROTO)
17 17
18 #include "vim9.h" 18 #include "vim9.h"
19 19
20 static char e_needs_vim9[] = N_("E1042: import/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 // TODO: go up the stack?
139 * ":import * as Name from 'filename'" 139 * ":import * as Name from 'filename'"
140 */ 140 */
141 void 141 void
142 ex_import(exarg_T *eap) 142 ex_import(exarg_T *eap)
143 { 143 {
144 if (current_sctx.sc_version != SCRIPT_VERSION_VIM9) 144 char_u *cmd_end = handle_import(eap->arg, NULL, current_sctx.sc_sid, NULL);
145 emsg(_(e_needs_vim9)); 145
146 else 146 if (cmd_end != NULL)
147 { 147 eap->nextcmd = check_nextcmd(cmd_end);
148 char_u *cmd_end = handle_import(eap->arg, NULL,
149 current_sctx.sc_sid, NULL);
150
151 if (cmd_end != NULL)
152 eap->nextcmd = check_nextcmd(cmd_end);
153 }
154 } 148 }
155 149
156 /* 150 /*
157 * Find an exported item in "sid" matching the name at "*argp". 151 * Find an exported item in "sid" matching the name at "*argp".
158 * When it is a variable return the index. 152 * When it is a variable return the index.