]> granicus.if.org Git - vim/commitdiff
patch 8.2.4132: Vim9: wrong error message when autoload script can't be found v8.2.4132
authorBram Moolenaar <Bram@vim.org>
Tue, 18 Jan 2022 13:14:47 +0000 (13:14 +0000)
committerBram Moolenaar <Bram@vim.org>
Tue, 18 Jan 2022 13:14:47 +0000 (13:14 +0000)
Problem:    Vim9: wrong error message when autoload script can't be found.
Solution:   Correct check for using autoload with wrong name.

src/testdir/test_vim9_import.vim
src/version.c
src/vim9script.c

index 13530151a2a7e3568f0f361882123769aff73ece..79c1ca43e28ef20f7c3dcfdb1c8d40cfd00c748f 100644 (file)
@@ -1433,9 +1433,21 @@ def Test_import_autoload_fails()
 
   lines =<< trim END
       vim9script
-      import autoload 'doesNotExist.vim'
+      import autoload './doesNotExist.vim'
+  END
+  CheckScriptFailure(lines, 'E1264:')
+
+  lines =<< trim END
+      vim9script
+      import autoload '/dir/doesNotExist.vim'
   END
   CheckScriptFailure(lines, 'E1264:')
+
+  lines =<< trim END
+      vim9script
+      import autoload 'doesNotExist.vim'
+  END
+  CheckScriptFailure(lines, 'E1053: Could not import "doesNotExist.vim"')
 enddef
 
 " test disassembling an auto-loaded function starting with "debug"
index 64a607796722ed901737680636ee25ceeb92128e..8b9958a473f97417a7a973bf6cc377a5f96eb3d9 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4132,
 /**/
     4131,
 /**/
index 2038c78a0835cf7ad42733dab80a5c47dae699be..41df6bfc470ac5f32f792c03737b3ff8f5e45514 100644 (file)
@@ -411,7 +411,7 @@ handle_import(
     int                ret = FAIL;
     char_u     *as_name = NULL;
     typval_T   tv;
-    int                sid = -1;
+    int                sid = -2;
     int                res;
     long       start_lnum = SOURCING_LNUM;
     garray_T   *import_gap;
@@ -519,7 +519,7 @@ handle_import(
 
     if (res == FAIL || sid <= 0)
     {
-       semsg(_(is_autoload && sid <= 0
+       semsg(_(is_autoload && sid == -2
                    ? e_autoload_import_cannot_use_absolute_or_relative_path
                    : e_could_not_import_str), tv.vval.v_string);
        goto erret;