Skip to content

Commit

Permalink
fix: fixed type comparison having errors
Browse files Browse the repository at this point in the history
  • Loading branch information
alinalihassan committed Apr 24, 2023
1 parent 1bcccf7 commit 8d85145
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/liblesma/Symbol/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,21 @@ namespace lesma {
void setReturnType(lesma::Type *type) { returnType = type; }

bool isEqual(Type *rhs) {
if (this == nullptr && rhs == nullptr)
if (rhs == nullptr)
return false;

if (this->getBaseType() != rhs->getBaseType())
return false;

Type *thisElementType = this->getElementType();
Type *rhsElementType = rhs->getElementType();

if (thisElementType == nullptr && rhsElementType == nullptr)
return true;
if (this == nullptr || rhs == nullptr)
if (thisElementType == nullptr || rhsElementType == nullptr)
return false;
return this->getBaseType() == rhs->getBaseType() && this->getElementType()->isEqual(rhs->getElementType());

return thisElementType->isEqual(rhsElementType);
}

[[nodiscard]] std::string toString() const {
Expand Down

0 comments on commit 8d85145

Please sign in to comment.