浏览代码

[analyzer] Haxe is safe_for_all

closes #9591
Simon Krajewski 5 年之前
父节点
当前提交
1afccbbaf2
共有 2 个文件被更改,包括 13 次插入1 次删除
  1. 1 1
      src/optimization/analyzer.ml
  2. 12 0
      tests/unit/src/unit/issues/Issue9591.hx

+ 1 - 1
src/optimization/analyzer.ml

@@ -369,7 +369,7 @@ module ConstPropagation = DataFlow(struct
 		| Top,Top | Bottom,Bottom -> true
 		| Const ct1,Const ct2 -> ct1 = ct2
 		| Null t1,Null t2 -> t1 == t2
-		| EnumValue(i1,tl1),EnumValue(i2,tl2) -> i1 = i2 && List.for_all2 equals tl1 tl2
+		| EnumValue(i1,tl1),EnumValue(i2,tl2) -> i1 = i2 && safe_for_all2 equals tl1 tl2
 		| ModuleType(mt1,_),ModuleType (mt2,_) -> mt1 == mt2
 		| _ -> false
 

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

@@ -0,0 +1,12 @@
+package unit.issues;
+
+private enum E {
+	A(?a:Int);
+}
+
+class Issue9591 extends Test {
+	function test() {
+		var x = if (Math.random() > 0.5) A(0) else A();
+		utest.Assert.pass();
+	}
+}