comparison src/testdir/test_user_func.vim @ 33613:31fb1a760ad6 v9.0.2050

patch 9.0.2050: Vim9: crash with deferred function call and exception Commit: https://github.com/vim/vim/commit/c59c1e0d88651a71ece7366e418f1253abbe2a28 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Thu Oct 19 10:52:34 2023 +0200 patch 9.0.2050: Vim9: crash with deferred function call and exception 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: #13376 closes: #13377 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
author Christian Brabandt <cb@256bit.org>
date Thu, 19 Oct 2023 11:00:07 +0200
parents 28605af12602
children 53416c49a7ab
comparison
equal deleted inserted replaced
33612:0dd1e3a17f68 33613:31fb1a760ad6
871 endfunc 871 endfunc
872 872
873 " Test for calling a deferred function after an exception 873 " Test for calling a deferred function after an exception
874 func Test_defer_after_exception() 874 func Test_defer_after_exception()
875 let g:callTrace = [] 875 let g:callTrace = []
876 func Bar()
877 let g:callTrace += [1]
878 throw 'InnerException'
879 endfunc
880
876 func Defer() 881 func Defer()
877 let g:callTrace += ['a'] 882 let g:callTrace += [2]
878 let g:callTrace += ['b'] 883 let g:callTrace += [3]
879 let g:callTrace += ['c'] 884 try
880 let g:callTrace += ['d'] 885 call Bar()
886 catch /InnerException/
887 let g:callTrace += [4]
888 endtry
889 let g:callTrace += [5]
890 let g:callTrace += [6]
881 endfunc 891 endfunc
882 892
883 func Foo() 893 func Foo()
884 defer Defer() 894 defer Defer()
885 throw "TestException" 895 throw "TestException"
886 endfunc 896 endfunc
887 897
888 try 898 try
889 call Foo() 899 call Foo()
890 catch /TestException/ 900 catch /TestException/
891 let g:callTrace += ['e'] 901 let g:callTrace += [7]
892 endtry 902 endtry
893 call assert_equal(['a', 'b', 'c', 'd', 'e'], g:callTrace) 903 call assert_equal([2, 3, 1, 4, 5, 6, 7], g:callTrace)
894 904
895 delfunc Defer 905 delfunc Defer
896 delfunc Foo 906 delfunc Foo
897 unlet g:callTrace 907 unlet g:callTrace
898 endfunc 908 endfunc