mirror of
https://github.com/vim/vim.git
synced 2025-10-03 05:14:07 -04:00
patch 8.2.4499: Vim9: at the script level declarations leak to next block
Problem: Vim9: at the script level declarations leak from try block to catch and finally block. Solution: End the block and start a new one. (closes #9883)
This commit is contained in:
@@ -763,6 +763,30 @@ def Test_try_catch_throw()
|
||||
v9.CheckDefAndScriptSuccess(lines)
|
||||
enddef
|
||||
|
||||
def Test_try_var_decl()
|
||||
var lines =<< trim END
|
||||
vim9script
|
||||
try
|
||||
var in_try = 1
|
||||
assert_equal(1, get(s:, 'in_try', -1))
|
||||
throw "getout"
|
||||
catch
|
||||
var in_catch = 2
|
||||
assert_equal(-1, get(s:, 'in_try', -1))
|
||||
assert_equal(2, get(s:, 'in_catch', -1))
|
||||
finally
|
||||
var in_finally = 3
|
||||
assert_equal(-1, get(s:, 'in_try', -1))
|
||||
assert_equal(-1, get(s:, 'in_catch', -1))
|
||||
assert_equal(3, get(s:, 'in_finally', -1))
|
||||
endtry
|
||||
assert_equal(-1, get(s:, 'in_try', -1))
|
||||
assert_equal(-1, get(s:, 'in_catch', -1))
|
||||
assert_equal(-1, get(s:, 'in_finally', -1))
|
||||
END
|
||||
v9.CheckScriptSuccess(lines)
|
||||
enddef
|
||||
|
||||
def Test_try_ends_in_return()
|
||||
var lines =<< trim END
|
||||
vim9script
|
||||
|
Reference in New Issue
Block a user