Prechádzať zdrojové kódy

[analyzer] don't appent ordered values to the unreachable block

closes #9883
Simon Krajewski 5 rokov pred
rodič
commit
cadaa54e15

+ 6 - 2
src/optimization/analyzerTexprTransformer.ml

@@ -202,8 +202,12 @@ let rec func ctx bb tf t p =
 			end
 		) (false,[]) (List.rev el) in
 		let bb,values = List.fold_left (fun (bb,acc) (aff,opt,e) ->
-			let bb,value = if aff || opt then bind_to_temp bb aff e else value bb e in
-			bb,(value :: acc)
+			if bb == g.g_unreachable then
+				bb,acc
+			else begin
+				let bb,value = if aff || opt then bind_to_temp bb aff e else value bb e in
+				bb,(value :: acc)
+			end
 		) (bb,[]) el in
 		bb,List.rev values
 	and bind_to_temp ?(v=None) bb sequential e =

+ 24 - 0
tests/unit/src/unit/issues/Issue9883.hx

@@ -0,0 +1,24 @@
+package unit.issues;
+
+class Issue9883 extends unit.Test {
+	function test() {
+		eq("ok", silly());
+	}
+
+	static function callMe(d:Dynamic, f:Dynamic) {}
+
+	static function silly() {
+		callMe(return "ok", () -> {});
+		// This is unreachable, but our control flow detection chokes on this too...
+		return "not ok";
+	}
+
+	static function silly2() {
+		new SillyClass(return "ok", () -> {});
+		return "not ok";
+	}
+}
+
+private class SillyClass {
+	public function new(d:Dynamic, f:Dynamic) {}
+}