Fix a bug in AbstractBase::operator==()

If both abstracts are "undetermined", they should considered equal.
This bug was introduced by a previous refectoring of operator==().
This commit is contained in:
He Wei 2021-12-16 17:30:44 +08:00
parent 9558ba49d8
commit c3980db2dd
1 changed files with 15 additions and 4 deletions

View File

@ -94,10 +94,21 @@ bool AbstractBase::operator==(const AbstractBase &other) const {
// Same object.
return true;
}
return tid() == other.tid() && // c++ type equal and
IsEqual(type_, other.type_) && // type equal and
IsEqual(shape_, other.shape_) && // shape equal and
IsEqual(value_, other.value_); // value equal.
// Check C++ type.
if (tid() != other.tid()) {
return false;
}
// Check data type.
if (!IsEqual(type_, other.type_)) {
return false;
}
// If both are "undetermined" type, they are considered equal.
if (type_ == kAnyType && BuildType()->type_id() == kObjectTypeUndeterminedType &&
other.BuildType()->type_id() == kObjectTypeUndeterminedType) {
return true;
}
// Check shape and value.
return IsEqual(shape_, other.shape_) && IsEqual(value_, other.value_);
}
ValuePtr AbstractBase::BuildValue() const {