Explorar el Código

fix `Not_found` exception related to try/catch (closes #5851)

Simon Krajewski hace 8 años
padre
commit
cbfc65582b

+ 1 - 0
extra/CHANGES.txt

@@ -4,6 +4,7 @@
 
 	all : fixed top-down inference infinite recursion issue (#5848)
 	all : fixed regression in Compiler.include (#5847)
+	all : fixed Not_found exception related to try/catch (#5851)
 
 2016-11-29: 3.4.0-RC1
 

+ 1 - 1
src/optimization/analyzerTexprTransformer.ml

@@ -481,7 +481,7 @@ let rec func ctx bb tf t p =
 			let bb_try_next = block bb_try e1 in
 			close();
 			(* We always want to keep catch-blocks, so let's add a pseudo CFG edge if it's unreachable. *)
-			if bb_exc.bb_incoming = [] then add_cfg_edge bb_try_next bb_exc CFGMaybeThrow;
+			if bb_exc.bb_incoming = [] then add_cfg_edge (if bb_try_next == g.g_unreachable then bb_try else bb_try_next) bb_exc CFGMaybeThrow;
 			let is_reachable = ref (not (bb_try_next == g.g_unreachable)) in
 			let catches = List.map (fun (v,e) ->
 				let bb_catch = create_node (BKCatch v) e.etype e.epos in

+ 12 - 0
tests/unit/src/unit/issues/Issue5851.hx

@@ -0,0 +1,12 @@
+package unit.issues;
+
+class Issue5851 extends unit.Test {
+	function test() {
+		try {
+			return "";
+		} catch ( s : Dynamic ) {
+			return "";
+		}
+		return "";
+	}
+}