0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.0368: Vim9: import that redefines local variable does not fail

Problem:    Vim9: import that redefines local variable does not fail.
Solution:   Check for already defined symbols.
This commit is contained in:
Bram Moolenaar
2020-03-09 19:25:27 +01:00
parent 3a2505cc18
commit 5269bd2a72
6 changed files with 63 additions and 7 deletions

View File

@@ -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)