fix: Avoid displaying spurious conflicts #371
No reviewers
Labels
No labels
Compat/Breaking
Kind
Bad merge
Kind
Bug
Kind
Documentation
Kind
Enhancement
Kind
Feature
Kind
New language
Kind
Security
Kind
Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: mergiraf/mergiraf#371
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "wetneb/mergiraf:356-spurious-conflicts"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #356.
Not including the original case as integration test case because I didn't manage to minimize it sufficiently. I think the unit test is enough.
Hm, I don't think this is the right approach to the problem – it's of course nice (especially for the end user) to graciously handle these spurious conflicts, but imo we should try to find the reason such conflicts appear in the first place, like with #170
Or maybe we could merge this as is, and then I could investigate the issue when I have time?
I agree that it feels unsatisfactory to have this check at such a downstream case, but to me it's a legitimate safety belt to add. Conflicts with identical sides can be created in at least two places:
left == right
case there too). It's not clear to me if it would be much more efficientMaybe the logic between those two places could be shared in a helper method that creates a
Conflict
or a list ofExactTree
depending on whether any two of the three sides are isomorphic or not. I'd still keep the downstream check to make sure we never output spurious conflicts, it's cheap enough, no?3fba8c55f7
to5fc178a961
fe9036124e
to3e560bead7
3e560bead7
tocd351b0470
cd351b0470
to609133ae78
609133ae78
to165400d47f
I've added another commit to check for the isomorphism of sides earlier on, which can help catch some spurious conflicts in the presence of reformatting. Sadly, the method I introduced for that (
MergedTree::new_conflict
) can't be used in the other place where we create conflicts (the highlighting of duplicate signatures) because at that stage we need to check for isomorphism of merged trees directly, so it's not quite the same code.@ -115,0 +118,4 @@
left: Vec<&'a AstNode<'a>>,
right: Vec<&'a AstNode<'a>>,
class_mapping: &ClassMapping<'a>,
) -> Vec<Self> {
it's a bit weird that we return a vec in a method which says it should return a conflict normally, and I guess we could use
Either<Self, Vec<Self>>
, but the value of that would be... questionableother than that, I really like that we've extracted this somewhat messy logic into a method!
Yes it's a bit wonky… By the way, I originally tried to make this method return iterators directly, since all we do is just append those elements to another vector, but I convinced myself that the ownership rules make that unfeasible. Do you agree?
Oh, thanks for the heads-up! I played a bit around with it, and did in fact manage to do that. Granted, I ended up needing the
Either
after all... I'll try opening a PR to your branch to demonstrate the steps, see if you like the end resultI'm not really concerned with efficiency in this case to be fair -- what I fear is that noticing the spurious conflict too late might lead to actual correctness issues, like with #170
Yeah yeah I'm sure it'll be plenty cheap. Let's keep it
into_iter
2aab49821dimpl Iterator
30520f9da5move
to fix the ownership problem 82ddd32cfeEither
to avoid the "different types" error 92faed6fdfiter::once
to make the overallEither
anIterator