Explorar o código

[analyzer] fix more control flow detection

Simon Krajewski %!s(int64=9) %!d(string=hai) anos
pai
achega
0e9fc0681d

+ 5 - 5
src/optimization/analyzerTexpr.ml

@@ -628,7 +628,9 @@ module Fusion = struct
 							e2,el
 						in
 					if !found then e else match e.eexpr with
-						| TWhile _ | TFunction _ ->
+						| TWhile _ | TTry _ ->
+							raise Exit
+						| TFunction _ ->
 							e
 						| TIf(e1,e2,eo) ->
 							let e1 = replace e1 in
@@ -641,6 +643,7 @@ module Fusion = struct
 								| Lua | Python -> explore e1
 								| _ -> replace e1
 							in
+							if not !found then raise Exit;
 							{e with eexpr = TSwitch(e1,cases,edef)}
 						| TLocal v2 when v1 == v2 && not !blocked ->
 							found := true;
@@ -717,10 +720,7 @@ module Fusion = struct
 						| e :: el ->
 							let e = replace e in
 							if !found then (List.rev (e :: acc)) @ el
-							else begin match e.eexpr with
-								| TWhile _ | TIf _ | TSwitch _ | TTry _ -> raise Exit
-								| _ -> loop (e :: acc) el
-							end
+							else loop (e :: acc) el
 						| [] ->
 							List.rev acc
 					in

+ 2 - 0
tests/unit/src/unit/issues/Issue5556.hx

@@ -3,7 +3,9 @@ package unit.issues;
 class Issue5556 extends unit.Test {
 	function test() {
 		var x = dynamicFunc(randomCall());
+		#if !flash
 		eq(1, x);
+		#end
 	}
 
 	static function randomCall() {

+ 11 - 0
tests/unit/src/unit/issues/Issue5557.hx

@@ -0,0 +1,11 @@
+package unit.issues;
+
+class Issue5557 extends unit.Test {
+	function test() {
+		var a = ["foo"];
+		var v = a.pop();
+		for (o in a)
+			throw o;
+		eq("foo", v);
+	}
+}