Merge pull request #1139 from ConsenSys/fix/bitvec_eq

Handle __eq__ and __ne__ for BitVecs with different sizes
pull/1140/head
Bernhard Mueller 5 years ago committed by GitHub
commit 5f1d7112ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      mythril/laser/smt/bitvec.py

@ -190,6 +190,8 @@ class BitVec(Expression[z3.BitVecRef]):
) )
union = self.annotations.union(other.annotations) union = self.annotations.union(other.annotations)
if self.raw.size() != other.raw.size():
return Bool(z3.BoolVal(False), annotations=union)
# MYPY: fix complaints due to z3 overriding __eq__ # MYPY: fix complaints due to z3 overriding __eq__
return Bool(cast(z3.BoolRef, self.raw == other.raw), annotations=union) return Bool(cast(z3.BoolRef, self.raw == other.raw), annotations=union)
@ -208,6 +210,8 @@ class BitVec(Expression[z3.BitVecRef]):
) )
union = self.annotations.union(other.annotations) union = self.annotations.union(other.annotations)
if self.raw.size() != other.raw.size():
return Bool(z3.BoolVal(True), annotations=union)
# MYPY: fix complaints due to z3 overriding __eq__ # MYPY: fix complaints due to z3 overriding __eq__
return Bool(cast(z3.BoolRef, self.raw != other.raw), annotations=union) return Bool(cast(z3.BoolRef, self.raw != other.raw), annotations=union)

Loading…
Cancel
Save