0
0
mirror of https://github.com/vim/vim.git synced 2025-09-30 04:44:14 -04:00

patch 8.2.1233: Vim9: various errors not caught by try/catch

Problem:    Vim9: various errors not caught by try/catch.
Solution:   Do not bail out if an error is inside try/catch.
This commit is contained in:
Bram Moolenaar
2020-07-17 23:03:17 +02:00
parent b68ced5f07
commit f0b9f43c31
3 changed files with 71 additions and 24 deletions

View File

@@ -17,6 +17,7 @@ let g:inc_counter = 1
let $SOME_ENV_VAR = 'some'
let g:alist = [7]
let g:astring = 'text'
let g:anumber = 123
def Test_assignment()
let bool1: bool = true
@@ -534,6 +535,13 @@ def Test_try_catch()
try
n = s:does_not_exist
catch /E121:/
n = 111
endtry
assert_equal(111, n)
try
n = g:does_not_exist
catch /E121:/
n = 121
endtry
@@ -546,6 +554,50 @@ def Test_try_catch()
n = 222
endtry
assert_equal(222, n)
try
n = -g:astring
catch /E39:/
n = 233
endtry
assert_equal(233, n)
try
n = +g:astring
catch /E1030:/
n = 244
endtry
assert_equal(244, n)
try
n = +g:alist
catch /E745:/
n = 255
endtry
assert_equal(255, n)
let nd: dict<any>
try
nd = {g:anumber: 1}
catch /E1029:/
n = 266
endtry
assert_equal(266, n)
try
[n] = [1, 2, 3]
catch /E1093:/
n = 277
endtry
assert_equal(277, n)
# TODO: make this work
# try
# &ts = g:astring
# catch /E1093:/
# n = 288
# endtry
# assert_equal(288, n)
enddef
def ThrowFromDef()