You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The TIM Improves Merging project found that crosshair diffbehavior can't detect a change when it appears in the method of an object that is passed into the function. This discussion is in section 4.2, "Inheritance", in the report PDF.
Note it looks like the issue has to do with inheritance, but really any behavior that's attached to the argument. Here is a small example:
$ cat version1.py
import dataclasses
@dataclasses.dataclass
class Obj:
num: int
def action(self):
self.num+=2
def o(a: Obj):
a.action()
return a.num
$ diff version1.py version2.py
7c7
< self.num+=2
---
> self.num+=4
$ crosshair diffbehavior version1.o version2.o
No differences found. (attempted 2 iterations)
All paths exhausted, functions are likely the same!
Why? Because CrossHair takes the exact same input for one function and passes it to the other. In the case of a user-defined instance, that means the instance will have the same behavior on both sides.
Note that the change will be detectable when running diff_behavior directly on the changed method; e.g.:
$ crosshair diffbehavior version1.Obj.action version2.Obj.action
Given: (self=Obj(num=-14)),
version1.Obj.action : after execution self=Obj(num=-12)
version2.Obj.action : after execution self=Obj(num=-10)
So, should we leave diffbehavior as-is? The only other idea would be to try and construct an "equivalent" instance on the other side. But it's pretty complex to understand when we mean by that. What if the data members of the class change? What if the type of the argument is legitimately changed to be a different class?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The TIM Improves Merging project found that crosshair
diffbehavior
can't detect a change when it appears in the method of an object that is passed into the function. This discussion is in section 4.2, "Inheritance", in the report PDF.Note it looks like the issue has to do with inheritance, but really any behavior that's attached to the argument. Here is a small example:
Why? Because CrossHair takes the exact same input for one function and passes it to the other. In the case of a user-defined instance, that means the instance will have the same behavior on both sides.
Note that the change will be detectable when running diff_behavior directly on the changed method; e.g.:
So, should we leave diffbehavior as-is? The only other idea would be to try and construct an "equivalent" instance on the other side. But it's pretty complex to understand when we mean by that. What if the data members of the class change? What if the type of the argument is legitimately changed to be a different class?
Let's collect thoughts and opinions here.
Beta Was this translation helpful? Give feedback.
All reactions