mirror of
https://github.com/neovim/neovim.git
synced 2025-11-17 07:41:27 +00:00
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
0672595fd5
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
@@ -3296,8 +3296,23 @@ static void handle_defer_one(funccall_T *funccal)
|
||||
char *name = dr->dr_name;
|
||||
dr->dr_name = NULL;
|
||||
|
||||
// If the deferred function is called after an exception, then only the
|
||||
// first statement in the function will be executed. Save and restore
|
||||
// the try/catch/throw exception state.
|
||||
const int save_trylevel = trylevel;
|
||||
const bool save_did_throw = did_throw;
|
||||
const bool save_need_rethrow = need_rethrow;
|
||||
|
||||
trylevel = 0;
|
||||
did_throw = false;
|
||||
need_rethrow = false;
|
||||
|
||||
call_func(name, -1, &rettv, dr->dr_argcount, dr->dr_argvars, &funcexe);
|
||||
|
||||
trylevel = save_trylevel;
|
||||
did_throw = save_did_throw;
|
||||
need_rethrow = save_need_rethrow;
|
||||
|
||||
tv_clear(&rettv);
|
||||
xfree(name);
|
||||
for (int i = dr->dr_argcount - 1; i >= 0; i--) {
|
||||
|
||||
Reference in New Issue
Block a user