diff --git a/claripy/ast/base.py b/claripy/ast/base.py index 4f1442edf..0c4c2e0a7 100644 --- a/claripy/ast/base.py +++ b/claripy/ast/base.py @@ -470,41 +470,12 @@ def _encoded_name(self) -> bytes: self._cached_encoded_name = self.args[0].encode() return self._cached_encoded_name - def _check_args_same(self, other_args: tuple[ArgType, ...], lenient_names=False) -> bool: - """ - Check if two ASTs are the same. - """ - # Several types inside of args don't support normall == comparison, so if we see those, - # we need compare them manually. - for a, b in zip(self.args, other_args, strict=True): - if isinstance(a, Base) and isinstance(b, Base): - if a._hash != b._hash: - return False - continue - if isinstance(a, float) and isinstance(b, float): - if math.isnan(a) and math.isnan(b): - continue - if math.isinf(a) and math.isinf(b): - continue - if a != b: - return False - if lenient_names and isinstance(a, str) and isinstance(b, str): - continue - if a != b: - return False - - return True - - def identical(self, other: Self, strict=False) -> bool: + def identical(self, other: Self) -> bool: """ Check if two ASTs are identical. If `strict` is False, the comparison will be lenient on the names of the ASTs. """ - return self._hash == other._hash or ( - self.op == other.op - and self._check_args_same(other.args, lenient_names=not strict) - and self.annotations == other.annotations - ) + return self.canonicalize() is other.canonicalize() # # Annotations diff --git a/claripy/ast/bv.py b/claripy/ast/bv.py index fee0b1cd9..eb4429e55 100644 --- a/claripy/ast/bv.py +++ b/claripy/ast/bv.py @@ -190,10 +190,10 @@ def raw_to_bv(self): def to_bv(self): return self.raw_to_bv() - def identical(self, other: Self, strict=False) -> bool: + def identical(self, other: Self) -> bool: with suppress(BackendError): return claripy.backends.vsa.convert(self).identical(claripy.backends.vsa.convert(other)) - return super().identical(other, strict) + return super().identical(other) def BVS( # pylint:disable=redefined-builtin