diff src/ex_eval.c @ 33636:53416c49a7ab v9.0.2059

patch 9.0.2059: outstanding exceptions may be skipped Commit: https://github.com/vim/vim/commit/0ab500dede4edd8d5aee7ddc63444537be527871 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Sat Oct 21 11:59:42 2023 +0200 patch 9.0.2059: outstanding exceptions may be skipped Problem: outstanding exceptions may be skipped Solution: When restoring exception state, process remaining outstanding exceptions closes: #13386 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
author Christian Brabandt <cb@256bit.org>
date Sat, 21 Oct 2023 12:15:03 +0200
parents 31fb1a760ad6
children
line wrap: on
line diff
--- a/src/ex_eval.c
+++ b/src/ex_eval.c
@@ -757,6 +757,7 @@ exception_state_save(exception_state_T *
     estate->estate_did_throw = did_throw;
     estate->estate_need_rethrow = need_rethrow;
     estate->estate_trylevel = trylevel;
+    estate->estate_did_emsg = did_emsg;
 }
 
 /*
@@ -765,11 +766,14 @@ exception_state_save(exception_state_T *
     void
 exception_state_restore(exception_state_T *estate)
 {
-    if (current_exception == NULL)
-	current_exception = estate->estate_current_exception;
-    did_throw |= estate->estate_did_throw;
-    need_rethrow |= estate->estate_need_rethrow;
-    trylevel |= estate->estate_trylevel;
+    // Handle any outstanding exceptions before restoring the state
+    if (did_throw)
+	handle_did_throw();
+    current_exception = estate->estate_current_exception;
+    did_throw = estate->estate_did_throw;
+    need_rethrow = estate->estate_need_rethrow;
+    trylevel = estate->estate_trylevel;
+    did_emsg = estate->estate_did_emsg;
 }
 
 /*
@@ -782,6 +786,7 @@ exception_state_clear(void)
     did_throw = FALSE;
     need_rethrow = FALSE;
     trylevel = 0;
+    did_emsg = 0;
 }
 
 /*