summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-12-14 12:06:16 +0000
committerBram Moolenaar <Bram@vim.org>2021-12-14 12:06:16 +0000
commitf8a79fc3468645019532331bf8b36d1f7b403ef4 (patch)
tree33a4264d26e261e707ac11e01e78f97a50e91ea8
parentc2958585f6c7ce4d822d3191ba501c0757b3ffff (diff)
patch 8.2.3807: Vim9: can call import with star directlyv8.2.3807
Problem: Vim9: can call import with star directly. Solution: Check that the import used star.
-rw-r--r--src/eval.c2
-rw-r--r--src/testdir/test_vim9_script.vim15
-rw-r--r--src/userfunc.c11
-rw-r--r--src/version.c2
4 files changed, 28 insertions, 2 deletions
diff --git a/src/eval.c b/src/eval.c
index b2673dcf21..abfde87f35 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -2001,7 +2001,7 @@ eval_func(
// Need to make a copy, in case evaluating the arguments makes
// the name invalid.
s = vim_strsave(s);
- if (s == NULL || (flags & EVAL_CONSTANT))
+ if (s == NULL || *s == NUL || (flags & EVAL_CONSTANT))
ret = FAIL;
else
{
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim
index 4b05e9cf10..9ab3b6dafe 100644
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -1536,6 +1536,21 @@ def Test_import_star_fails()
CheckScriptFailure(lines, 'E1047:')
delete('Xfoo.vim')
+
+ lines =<< trim END
+ vim9script
+ def TheFunc()
+ echo 'the func'
+ enddef
+ export var Ref = TheFunc
+ END
+ writefile([], 'Xthat.vim')
+ lines =<< trim END
+ import * as That from './Xthat.vim'
+ That()
+ END
+ CheckDefAndScriptFailure2(lines, 'E1094:', 'E1236: Cannot use That itself')
+ delete('Xthat.vim')
enddef
def Test_import_as()
diff --git a/src/userfunc.c b/src/userfunc.c
index 42fa492d79..5f2ede753b 100644
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -1596,7 +1596,16 @@ deref_func_name(
*lenp = (int)STRLEN(s);
return s;
}
- // TODO: what if (import->imp_flags & IMP_FLAGS_STAR)
+ if (import->imp_flags & IMP_FLAGS_STAR)
+ {
+ name[len] = NUL;
+ semsg(_(e_cannot_use_str_itself_it_is_imported_with_star),
+ name);
+ name[len] = cc;
+ *lenp = 0;
+ return (char_u *)""; // just in case
+ }
+ else
{
scriptitem_T *si = SCRIPT_ITEM(import->imp_sid);
svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data)
diff --git a/src/version.c b/src/version.c
index 3098c59c6f..08bfba17be 100644
--- a/src/version.c
+++ b/src/version.c
@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3807,
+/**/
3806,
/**/
3805,