Skip to content

Commit

Permalink
[analyzer] don't recursively check enum values when const propagating
Browse files Browse the repository at this point in the history
closes #11429
  • Loading branch information
Simn committed Dec 14, 2023
1 parent ce19684 commit 1366686
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/optimization/analyzer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,11 @@ module ConstPropagation = DataFlow(struct
let top = Top
let bottom = Bottom

let rec equals lat1 lat2 = match lat1,lat2 with
let equals lat1 lat2 = match lat1,lat2 with
| 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 && safe_for_all2 equals tl1 tl2
| EnumValue(i1,[]),EnumValue(i2,[]) -> i1 = i2
| ModuleType(mt1,_),ModuleType (mt2,_) -> mt1 == mt2
| _ -> false

Expand Down
19 changes: 19 additions & 0 deletions tests/unit/src/unit/issues/Issue11429.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package unit.issues;

private enum Foo {
FooRec(foo:Foo);
}

class Issue11429 extends Test {
function test() {
blowUp([]);
utest.Assert.pass();
}

public static function blowUp(arr:Array<Foo>) {
var qp = FooRec(arr.pop());
while (arr.length > 0) {
qp = FooRec(qp);
}
}
}

0 comments on commit 1366686

Please sign in to comment.