File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -584,11 +584,17 @@ def __eq__(self, other: object) -> object: # type: ignore[override]
584584 if (method := _get_expr_method (self , "__eq__" )) is not None :
585585 return method (other )
586586
587- # TODO: Check if two objects can be upcasted to be the same. If not, then return NotImplemented so other
588- # expr gets a chance to resolve __eq__ which could be a preserved method.
589- from .egraph import BaseExpr , eq # noqa: PLC0415
587+ if not (isinstance (self , RuntimeExpr ) and isinstance (other , RuntimeExpr )):
588+ return NotImplemented
589+ if self .__egg_typed_expr__ .tp != other .__egg_typed_expr__ .tp :
590+ return NotImplemented
590591
591- return eq (cast ("BaseExpr" , self )).to (cast ("BaseExpr" , other ))
592+ from .egraph import Fact # noqa: PLC0415
593+
594+ return Fact (
595+ Declarations .create (self , other ),
596+ EqDecl (self .__egg_typed_expr__ .tp , self .__egg_typed_expr__ .expr , other .__egg_typed_expr__ .expr ),
597+ )
592598
593599 def __ne__ (self , other : object ) -> object : # type: ignore[override]
594600 if (method := _get_expr_method (self , "__ne__" )) is not None :
You can’t perform that action at this time.
0 commit comments