]> granicus.if.org Git - vim/commitdiff
patch 8.2.3807: Vim9: can call import with star directly v8.2.3807
authorBram Moolenaar <Bram@vim.org>
Tue, 14 Dec 2021 12:06:16 +0000 (12:06 +0000)
committerBram Moolenaar <Bram@vim.org>
Tue, 14 Dec 2021 12:06:16 +0000 (12:06 +0000)
Problem:    Vim9: can call import with star directly.
Solution:   Check that the import used star.

src/eval.c
src/testdir/test_vim9_script.vim
src/userfunc.c
src/version.c

index b2673dcf2127591756597587143daa918b4b2d26..abfde87f358b5f15d8d196128323bb1019c8bfdc 100644 (file)
@@ -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
     {
index 4b05e9cf1023a38a79b22ff9a5969129eb8525ca..9ab3b6dafe8304859ca948b77fba9a3a1f565502 100644 (file)
@@ -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()
index 42fa492d79856582e9a5c3a4912e68141d91728e..5f2ede753be8873395d250f44accfb88180fd863 100644 (file)
@@ -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)
index 3098c59c6fb88d799cd80b5d82f138285ea7435f..08bfba17be5b0458077602a9677c421fbf703041 100644 (file)
@@ -749,6 +749,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3807,
 /**/
     3806,
 /**/