patch 8.2.2774: Vim9: cannot import an existing name even when using "as"
Problem: Vim9: cannot import an existing name even when using "as".
Solution: Do not check for an existing name when using "as". (closes #8113)
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim
index d9ae4ff..2f2fc9c 100644
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -1280,6 +1280,8 @@
var import_lines =<< trim END
vim9script
+ var one = 'notused'
+ var yes = 777
import one as thatOne from './XexportAs'
assert_equal(1, thatOne)
import yes as yesYes from './XexportAs'
diff --git a/src/version.c b/src/version.c
index 113ba8f..5d26348 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2774,
+/**/
2773,
/**/
2772,
diff --git a/src/vim9script.c b/src/vim9script.c
index 796b7d1..583a8d4 100644
--- a/src/vim9script.c
+++ b/src/vim9script.c
@@ -600,7 +600,8 @@
}
else
{
- if (check_defined(name, len, cctx, FALSE) == FAIL)
+ if (as_name == NULL
+ && check_defined(name, len, cctx, FALSE) == FAIL)
goto erret;
imported = new_imported(gap != NULL ? gap