diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-02-19 17:06:11 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-02-19 17:06:11 +0100 |
commit | 257cc5ee9593cd0653beca8b5945dc7fbf7f2d8d (patch) | |
tree | dcbecc0c8309f33837bad940e9665b3f703ffc28 /src | |
parent | 63ce4849efa54d3980446ad337d0e1248ec86182 (diff) |
patch 8.2.0280: Vim9: throw in :def function not caught higher upv8.2.0280
Problem: Vim9: throw in :def function not caught higher up.
Solution: Set "need_rethrow".
Diffstat (limited to 'src')
-rw-r--r-- | src/testdir/test_vim9_script.vim | 28 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9execute.c | 1 |
3 files changed, 31 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim index 899a32aa6e..ae33935072 100644 --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -206,6 +206,34 @@ def Test_try_catch() assert_equal(['1', 'wrong', '3'], l) 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 vim9script let name: string = 'bob' diff --git a/src/version.c b/src/version.c index d748416cae..2ff3460757 100644 --- a/src/version.c +++ b/src/version.c @@ -739,6 +739,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 280, +/**/ 279, /**/ 278, diff --git a/src/vim9execute.c b/src/vim9execute.c index 4555748110..4349489e54 100644 --- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -482,6 +482,7 @@ call_def_function( tv->v_type = VAR_NUMBER; tv->vval.v_number = 0; ++ectx.ec_stack.ga_len; + need_rethrow = TRUE; goto done; } |