Mercurial > vim
comparison src/testdir/test_vim9_script.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 |
---|---|
4689 " Test for calling a deferred function after an exception | 4689 " Test for calling a deferred function after an exception |
4690 def Test_defer_after_exception() | 4690 def Test_defer_after_exception() |
4691 var lines =<< trim END | 4691 var lines =<< trim END |
4692 vim9script | 4692 vim9script |
4693 | 4693 |
4694 var callTrace: list<string> = [] | 4694 var callTrace: list<number> = [] |
4695 def Bar() | |
4696 callTrace += [1] | |
4697 throw 'InnerException' | |
4698 enddef | |
4699 | |
4695 def Defer() | 4700 def Defer() |
4696 callTrace += ['a'] | 4701 callTrace += [2] |
4697 callTrace += ['b'] | 4702 callTrace += [3] |
4698 callTrace += ['c'] | 4703 try |
4699 callTrace += ['d'] | 4704 Bar() |
4705 catch /InnerException/ | |
4706 callTrace += [4] | |
4707 endtry | |
4708 callTrace += [5] | |
4709 callTrace += [6] | |
4700 enddef | 4710 enddef |
4701 | 4711 |
4702 def Foo() | 4712 def Foo() |
4703 defer Defer() | 4713 defer Defer() |
4704 throw "TestException" | 4714 throw "TestException" |
4705 enddef | 4715 enddef |
4706 | 4716 |
4707 try | 4717 try |
4708 Foo() | 4718 Foo() |
4709 catch /TestException/ | 4719 catch /TestException/ |
4710 callTrace += ['e'] | 4720 callTrace += [7] |
4711 endtry | 4721 endtry |
4712 | 4722 |
4713 assert_equal(['a', 'b', 'c', 'd', 'e'], callTrace) | 4723 assert_equal([2, 3, 1, 4, 5, 6, 7], callTrace) |
4714 END | 4724 END |
4715 v9.CheckScriptSuccess(lines) | 4725 v9.CheckScriptSuccess(lines) |
4716 enddef | 4726 enddef |
4717 | 4727 |
4718 " Keep this last, it messes up highlighting. | 4728 " Keep this last, it messes up highlighting. |