diff src/testdir/test_vim9_script.vim @ 25260:a60895011da9 v8.2.3166

patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error" Commit: https://github.com/vim/vim/commit/b5841b99e678da187b68c21f46d56a608a0dc10c Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jul 15 18:09:53 2021 +0200 patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error" Problem: Vim9: nested autoload call error overruled by "Unknown error". Solution: Check need_rethrow before giving an "Unknown error". (closes #8568)
author Bram Moolenaar <Bram@vim.org>
date Thu, 15 Jul 2021 18:15:04 +0200
parents 658dfd6be868
children ca7a8ea2eb5f
line wrap: on
line diff
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -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.