diff src/testdir/test_vim9_script.vim @ 19445:6e27e1ffa2a6 v8.2.0280

patch 8.2.0280: Vim9: throw in :def function not caught higher up Commit: https://github.com/vim/vim/commit/257cc5ee9593cd0653beca8b5945dc7fbf7f2d8d Author: Bram Moolenaar <Bram@vim.org> Date: Wed Feb 19 17:06:11 2020 +0100 patch 8.2.0280: Vim9: throw in :def function not caught higher up Problem: Vim9: throw in :def function not caught higher up. Solution: Set "need_rethrow".
author Bram Moolenaar <Bram@vim.org>
date Wed, 19 Feb 2020 17:15:03 +0100
parents 6b1a59e71f85
children f8408ba21982
line wrap: on
line diff
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -206,6 +206,34 @@ def Test_try_catch()
   assert_equal(['1', 'wrong', '3'], l)
 enddef
 
+def ThrowFromDef()
+  throw 'getout'
+enddef
+
+func CatchInFunc()
+  try
+    call ThrowFromDef()
+  catch
+    let g:thrown_func = v:exception
+  endtry
+endfunc
+
+def CatchInDef()
+  try
+    ThrowFromDef()
+  catch
+    g:thrown_def = v:exception
+  endtry
+enddef
+
+def Test_try_catch_nested()
+  CatchInFunc()
+  assert_equal('getout', g:thrown_func)
+
+  CatchInDef()
+  assert_equal('getout', g:thrown_def)
+enddef
+
 let s:export_script_lines =<< trim END
   vim9script
   let name: string = 'bob'