0
0
mirror of https://github.com/vim/vim.git synced 2025-11-09 10:37:17 -05:00

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)
This commit is contained in:
Bram Moolenaar
2023-04-30 18:50:48 +01:00
parent 58a44751ce
commit 3ef2e41128
3 changed files with 69 additions and 7 deletions

View File

@@ -812,6 +812,41 @@ def Test_try_catch_throw()
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