Skip to content

Commit

Permalink
Merge pull request #2096 from usethesource/cycle-equality-bug
Browse files Browse the repository at this point in the history
Fixed bug where cycles where always considered unequal
  • Loading branch information
PieterOlivier authored Dec 9, 2024
2 parents 6ed70ad + a41d37d commit d83ff92
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,15 @@ protected Result<IBool> equalToConcreteSyntax(ConcreteSyntaxResult that) {
return bool(true, ctx);
}

if (TreeAdapter.isCycle(left) && TreeAdapter.isCycle(right)) {
IConstructor type1 = TreeAdapter.getCycleType(left);
IConstructor type2 = TreeAdapter.getCycleType(right);
int length1 = TreeAdapter.getCycleLength(left);
int length2 = TreeAdapter.getCycleLength(right);

return bool(type1.equals(type2) && length1 == length2, ctx);
}

return bool(false, ctx);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module lang::rascal::tests::concrete::ParseTreeEquality

import ParseTree;

bool testCycleEquality() {
Tree cycle1 = cycle(sort("X"), 3);
Tree cycle2 = cycle(sort("X"), 3);

return cycle1 == cycle2;
}

0 comments on commit d83ff92

Please sign in to comment.