0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

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".
This commit is contained in:
Bram Moolenaar
2020-02-19 17:06:11 +01:00
parent 63ce4849ef
commit 257cc5ee95
3 changed files with 31 additions and 0 deletions

View File

@@ -206,6 +206,34 @@ def Test_try_catch()
assert_equal(['1', 'wrong', '3'], l) assert_equal(['1', 'wrong', '3'], l)
enddef 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 let s:export_script_lines =<< trim END
vim9script vim9script
let name: string = 'bob' let name: string = 'bob'

View File

@@ -738,6 +738,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
280,
/**/ /**/
279, 279,
/**/ /**/

View File

@@ -482,6 +482,7 @@ call_def_function(
tv->v_type = VAR_NUMBER; tv->v_type = VAR_NUMBER;
tv->vval.v_number = 0; tv->vval.v_number = 0;
++ectx.ec_stack.ga_len; ++ectx.ec_stack.ga_len;
need_rethrow = TRUE;
goto done; goto done;
} }