patch 9.0.1501: crash with nested :try and :throw in catch block
Problem: Crash with nested :try and :throw in catch block.
Solution: Jump to :endtry before returning from function. (closes #12245)
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim
index 3d5148e..3541aa7 100644
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -812,6 +812,41 @@
v9.CheckDefAndScriptSuccess(lines)
enddef
+def Test_throw_in_nested_try()
+ var lines =<< trim END
+ vim9script
+
+ def Try(F: func(): void)
+ try
+ F()
+ catch
+ endtry
+ enddef
+
+ class X
+ def F()
+ try
+ throw 'Foobar'
+ catch
+ throw v:exception
+ endtry
+ enddef
+ endclass
+
+ def Test_TryMethod()
+ var x = X.new()
+ Try(() => x.F())
+ enddef
+
+
+ try
+ Test_TryMethod()
+ catch
+ endtry
+ END
+ v9.CheckScriptSuccess(lines)
+enddef
+
def Test_try_var_decl()
var lines =<< trim END
vim9script