diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2023-10-18 18:27:50 +0800 |
|---|---|---|
| committer | zeertzjq <zeertzjq@outlook.com> | 2023-10-18 18:29:47 +0800 |
| commit | 9e3640a7797bcc5f6015548842572a6ce951a861 (patch) | |
| tree | 477412bf56978d009949982a89b1102a0d8b156b /test | |
| parent | 831d662ac6756cab4fed6a9b394e68933b5fe325 (diff) | |
| download | rneovim-9e3640a7797bcc5f6015548842572a6ce951a861.tar.gz rneovim-9e3640a7797bcc5f6015548842572a6ce951a861.tar.bz2 rneovim-9e3640a7797bcc5f6015548842572a6ce951a861.zip | |
vim-patch:9.0.2044: Vim9: exceptions confuse defered functions
Problem: Vim9: exceptions confuse defered functions
Solution: save and restore exception state when calling defered
functions
closes: vim/vim#13364
closes: vim/vim#13372
https://github.com/vim/vim/commit/0672595fd50e9ae668676a40e28ebf66d7f52392
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'test')
| -rw-r--r-- | test/old/testdir/test_user_func.vim | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/old/testdir/test_user_func.vim b/test/old/testdir/test_user_func.vim index dc36ab98cb..ee1fd4ec5b 100644 --- a/test/old/testdir/test_user_func.vim +++ b/test/old/testdir/test_user_func.vim @@ -793,5 +793,31 @@ func Test_defer_wrong_arguments() call v9.CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected string but got number') endfunc +" Test for calling a deferred function after an exception +func Test_defer_after_exception() + let g:callTrace = [] + func Defer() + let g:callTrace += ['a'] + let g:callTrace += ['b'] + let g:callTrace += ['c'] + let g:callTrace += ['d'] + endfunc + + func Foo() + defer Defer() + throw "TestException" + endfunc + + try + call Foo() + catch /TestException/ + let g:callTrace += ['e'] + endtry + call assert_equal(['a', 'b', 'c', 'd', 'e'], g:callTrace) + + delfunc Defer + delfunc Foo + unlet g:callTrace +endfunc " vim: shiftwidth=2 sts=2 expandtab |