fix: Ignore empty nodes in AstNode::isomorphic_to_source #480

Merged
wetneb merged 3 commits from wetneb/fix_isomorphism into main 2025-07-07 22:43:24 +02:00 AGit
Owner

When checking that our merged output is isomorphic to our internal tree (as a consistency check), it can be that isomorphism fails because one of the sides contains extra empty nodes.

I think it makes sense to filter out those nodes to avoid that.

WIP because it depends of #478.

When checking that our merged output is isomorphic to our internal tree (as a consistency check), it can be that isomorphism fails because one of the sides contains extra empty nodes. I think it makes sense to filter out those nodes to avoid that. <s>WIP because it depends of #478.</s>
chore(go.mod): Update parser to 0.4.0
All checks were successful
/ test (pull_request) Successful in 1m52s
f7ad7f9f3b
This adds support for `ignore` and `godebug` directives,
bringing the parser on-par to the specs (as far as I can tell).
wetneb changed title from fix: Ignore empty nodes in AstNode::isomorphic_to_source to WIP: fix: Ignore empty nodes in AstNode::isomorphic_to_source 2025-07-07 19:33:27 +02:00
Owner

WIP because it depends of #478.

Not logically at least, I don't think? Unless it's the go.mod tests that revealed this issue, but still I think it would be to nice a have separate test for this..

> WIP because it depends of #478. Not logically at least, I don't think? Unless it's the go.mod tests that revealed this issue, but still I think it would be to nice a have separate test for this..
Author
Owner

Yes, the test I have included in 4c56d94338 is specific for this issue but uses a feature of go.mod that requires #478 to be parsed in the first place.

Yes, the test I have included in https://codeberg.org/mergiraf/mergiraf/commit/4c56d94338b68cc841442010462f482448004df6 is specific for this issue but uses a feature of `go.mod` that requires #478 to be parsed in the first place.
Owner

the test I have included in 4c56d94338

yes but that's an integration test -- I was wondering whether we could make just a unit test specifically for AstNode::isomorphic_to_source. Let me see if I can come up with something...

> the test I have included in 4c56d94338 yes but that's an integration test -- I was wondering whether we could make just a unit test specifically for `AstNode::isomorphic_to_source`. Let me see if I can come up with something...
Author
Owner

Given that it's a method of MergedTree, it involves creating a MergedTree instance… it would be great to be able to create those more easily for unit tests, but so far we've just being creating them by running the merge process, so it's not very far from an integration test.

Given that it's a method of `MergedTree`, it involves creating a `MergedTree` instance… it would be great to be able to create those more easily for unit tests, but so far we've just being creating them by running the merge process, so it's not very far from an integration test.
Owner

it would be great to be able to create those more easily for unit tests

Fully agree!

Maybe at least add a README.md saying that that integration test also tests the case fixed by this PR, and link the PR -- I'm sure that whoever stumbles upon a regression in this will be very thankful^^

> it would be great to be able to create those more easily for unit tests Fully agree! Maybe at least add a README.md saying that that integration test also tests the case fixed by this PR, and link the PR -- I'm sure that whoever stumbles upon a regression in this will be very thankful^^
@ -406,0 +407,4 @@
MergedChild::Original(child) => {
!child.source.is_empty()
},
MergedChild::Merged(MergedTree::ExactTree { node, revisions, .. }) => {
Owner

maybe reorder these two match arms to keep all the MergedChild::Mergeds together? Or you could put the MergedChild::Original case as the very first, since the MergedChild::Merged are roughly in the order of ascending complexity

maybe reorder these two match arms to keep all the `MergedChild::Merged`s together? Or you could put the `MergedChild::Original` case as the very first, since the `MergedChild::Merged` are _roughly_ in the order of ascending complexity
ada4a marked this conversation as resolved
wetneb force-pushed wetneb/fix_isomorphism from 4c56d94338 to adefd0dc90 2025-07-07 22:13:15 +02:00 Compare
wetneb changed title from WIP: fix: Ignore empty nodes in AstNode::isomorphic_to_source to fix: Ignore empty nodes in AstNode::isomorphic_to_source 2025-07-07 22:13:38 +02:00
wetneb force-pushed wetneb/fix_isomorphism from adefd0dc90 to bb0e1bacc2 2025-07-07 22:16:52 +02:00 Compare
Move MergedChild::Original case at the top
All checks were successful
/ test (pull_request) Successful in 55s
52c0af226b
Document the relationship between code and test
All checks were successful
/ test (pull_request) Successful in 59s
0fb87d6f6c
ada4a approved these changes 2025-07-07 22:33:17 +02:00
ada4a left a comment
Owner

Very nice!

Very nice!
wetneb merged commit d18cf1c489 into main 2025-07-07 22:43:24 +02:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: mergiraf/mergiraf#480
No description provided.