Bladeren bron

Ensure the error is set to the current result before we throw the error

Aidan Lee 5 maanden geleden
bovenliggende
commit
cfa641c237
2 gewijzigde bestanden met toevoegingen van 6 en 6 verwijderingen
  1. 1 0
      src/coro/coroToTexpr.ml
  2. 5 6
      tests/misc/coroutines/src/TestControlFlow.hx

+ 1 - 0
src/coro/coroToTexpr.ml

@@ -207,6 +207,7 @@ let block_to_texpr_coroutine ctx cb cls tf_args forbidden_vars econtinuation eco
 			let _ = loop bb_next [] in
 			let try_state_id = loop bb_try [] in
 			let erethrow = mk (TBlock [
+				mk_assign eerror eresult;
 				set_state (match catch.cc_cb.cb_catch with None -> cb_uncaught.cb_id | Some cb -> cb.cb_id);
 			]) t_dynamic null_pos in
 			let eif =

+ 5 - 6
tests/misc/coroutines/src/TestControlFlow.hx

@@ -95,12 +95,11 @@ class TestControlFlow extends utest.Test {
 		}));
 	}
 
-	// this seems to throw E3 but not catch it?
-	// function testTryCatchFail() {
-	// 	Assert.raises(() -> Coroutine.run(@:coroutine function run() {
-	// 		return tryCatch(new E3());
-	// 	}), E3);
-	// }
+	function testTryCatchFail() {
+		Assert.raises(() -> Coroutine.run(@:coroutine function run() {
+			return tryCatch(new E3());
+		}), E3);
+	}
 
 	function testRecursion() {
 		var maxIters = 3;