diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-03-09 19:25:27 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-03-09 19:25:27 +0100 |
commit | 5269bd2a724fdb8c16c9635ef744a670f1bc8bd5 (patch) | |
tree | 18c5fb9d7cd245085c16c86b6f2b05ed7a1530ac /src/vim9script.c | |
parent | 3a2505cc183b3c5f4852ae8a945172582fbc650f (diff) | |
download | vim-git-5269bd2a724fdb8c16c9635ef744a670f1bc8bd5.tar.gz |
patch 8.2.0368: Vim9: import that redefines local variable does not failv8.2.0368
Problem: Vim9: import that redefines local variable does not fail.
Solution: Check for already defined symbols.
Diffstat (limited to 'src/vim9script.c')
-rw-r--r-- | src/vim9script.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/vim9script.c b/src/vim9script.c index 6cea96bd0..ce5cfec92 100644 --- a/src/vim9script.c +++ b/src/vim9script.c @@ -143,7 +143,8 @@ ex_import(exarg_T *eap) emsg(_(e_needs_vim9)); else { - char_u *cmd_end = handle_import(eap->arg, NULL, current_sctx.sc_sid); + char_u *cmd_end = handle_import(eap->arg, NULL, + current_sctx.sc_sid, NULL); if (cmd_end != NULL) eap->nextcmd = check_nextcmd(cmd_end); @@ -238,7 +239,7 @@ find_exported( * Returns a pointer to after the command or NULL in case of failure */ char_u * -handle_import(char_u *arg_start, garray_T *gap, int import_sid) +handle_import(char_u *arg_start, garray_T *gap, int import_sid, void *cctx) { char_u *arg = arg_start; char_u *cmd_end; @@ -278,6 +279,8 @@ handle_import(char_u *arg_start, garray_T *gap, int import_sid) ++arg; as_len = (int)(arg - as_ptr); arg = skipwhite(arg); + if (check_defined(as_ptr, as_len, cctx) == FAIL) + return NULL; } else if (*arg_start == '*') { @@ -389,6 +392,9 @@ handle_import(char_u *arg_start, garray_T *gap, int import_sid) if (idx < 0 && ufunc == NULL) return NULL; + if (check_defined(name, name_len, cctx) == FAIL) + return NULL; + imported = new_imported(gap != NULL ? gap : &SCRIPT_ITEM(import_sid)->sn_imports); if (imported == NULL) |