]> granicus.if.org Git - vim/commitdiff
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error" v8.2.3166
authorBram Moolenaar <Bram@vim.org>
Thu, 15 Jul 2021 16:09:53 +0000 (18:09 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 15 Jul 2021 16:09:53 +0000 (18:09 +0200)
Problem:    Vim9: nested autoload call error overruled by "Unknown error".
Solution:   Check need_rethrow before giving an "Unknown error".
            (closes #8568)

src/testdir/test_vim9_script.vim
src/version.c
src/vim9execute.c

index b4107e97d16a5fb4911c98519b493aa2efaf8ecf..bd06f7a2e9e8b57249957425dc7ec3a2e3ab93ff 100644 (file)
@@ -3699,6 +3699,46 @@ def Test_script_var_in_autocmd()
   CheckScriptSuccess(lines)
 enddef
 
+def Test_error_in_autoload_script()
+  var save_rtp = &rtp
+  var dir = getcwd() .. '/Xruntime'
+  &rtp = dir
+  mkdir(dir .. '/autoload', 'p')
+
+  var lines =<< trim END
+      vim9script noclear
+      def script#autoloaded()
+      enddef
+      def Broken()
+        var x: any = ''
+        eval x != 0
+      enddef
+      Broken()
+  END
+  writefile(lines, dir .. '/autoload/script.vim')
+
+  lines =<< trim END
+      vim9script
+      def CallAutoloaded()
+        script#autoloaded()
+      enddef
+
+      function Legacy()
+        try
+          call s:CallAutoloaded()
+        catch
+          call assert_match('E1030: Using a String as a Number', v:exception)
+        endtry
+      endfunction
+
+      Legacy()
+  END
+  CheckScriptSuccess(lines)
+
+  &rtp = save_rtp
+  delete(dir, 'rf')
+enddef
+
 def Test_cmdline_win()
   # if the Vim syntax highlighting uses Vim9 constructs they can be used from
   # the command line window.
index ba8362bccf4345f4da56aae4baf825148be77710..896ca07b8b9459996cb7dcb8353032246ff15c3a 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3166,
 /**/
     3165,
 /**/
index 41249284dc0f7c5474b6a7999e6e4916d3f7a043..b882c4d111c2c9b364122fd9626ac2c90bac936b 100644 (file)
@@ -4737,7 +4737,8 @@ failed_early:
     // Not sure if this is necessary.
     suppress_errthrow = save_suppress_errthrow;
 
-    if (ret != OK && did_emsg_cumul + did_emsg == did_emsg_before)
+    if (ret != OK && did_emsg_cumul + did_emsg == did_emsg_before
+                                                             && !need_rethrow)
        semsg(_(e_unknown_error_while_executing_str),
                                                   printable_func_name(ufunc));
     funcdepth_restore(orig_funcdepth);