Skip to content

Commit

Permalink
Fixed bug where cycles where always considered unequal
Browse files Browse the repository at this point in the history
  • Loading branch information
PieterOlivier committed Dec 8, 2024
1 parent eda3949 commit a41d37d
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);

Check warning on line 254 in src/org/rascalmpl/interpreter/result/ConcreteSyntaxResult.java

View check run for this annotation

Codecov / codecov/patch

src/org/rascalmpl/interpreter/result/ConcreteSyntaxResult.java#L251-L254

Added lines #L251 - L254 were not covered by tests

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 a41d37d

Please sign in to comment.