From a0961659770ca41edcb5a6dcf28e7c7492eb60f0 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 19 Oct 2023 18:34:48 +0800 Subject: vim-patch:9.0.2050: Vim9: crash with deferred function call and exception (#25715) Problem: Vim9: crash with deferred function call and exception Solution: Save and restore exception state Crash when a deferred function is called after an exception and another exception is thrown closes: vim/vim#13376 closes: vim/vim#13377 https://github.com/vim/vim/commit/c59c1e0d88651a71ece7366e418f1253abbe2a28 The change in check_due_timer() is N/A as Nvim calls timer callbacks on the main loop. Co-authored-by: Yegappan Lakshmanan --- test/old/testdir/test_user_func.vim | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'test') diff --git a/test/old/testdir/test_user_func.vim b/test/old/testdir/test_user_func.vim index ee1fd4ec5b..d65f70445d 100644 --- a/test/old/testdir/test_user_func.vim +++ b/test/old/testdir/test_user_func.vim @@ -796,11 +796,21 @@ endfunc " Test for calling a deferred function after an exception func Test_defer_after_exception() let g:callTrace = [] + func Bar() + let g:callTrace += [1] + throw 'InnerException' + endfunc + func Defer() - let g:callTrace += ['a'] - let g:callTrace += ['b'] - let g:callTrace += ['c'] - let g:callTrace += ['d'] + let g:callTrace += [2] + let g:callTrace += [3] + try + call Bar() + catch /InnerException/ + let g:callTrace += [4] + endtry + let g:callTrace += [5] + let g:callTrace += [6] endfunc func Foo() @@ -811,9 +821,9 @@ func Test_defer_after_exception() try call Foo() catch /TestException/ - let g:callTrace += ['e'] + let g:callTrace += [7] endtry - call assert_equal(['a', 'b', 'c', 'd', 'e'], g:callTrace) + call assert_equal([2, 3, 1, 4, 5, 6, 7], g:callTrace) delfunc Defer delfunc Foo -- cgit