diff --git a/src/Binder/Binder.cpp b/src/Binder/Binder.cpp index 59b51ab..07a018b 100644 --- a/src/Binder/Binder.cpp +++ b/src/Binder/Binder.cpp @@ -421,21 +421,26 @@ namespace Porygon::Binder { auto boundLeftType = boundLeft->GetType(); auto boundRightType = boundRight->GetType(); + auto kind = expression->GetOperatorKind(); if (boundLeftType->GetClass() == TypeClass::UserData){ auto ud = dynamic_pointer_cast(boundLeftType); - auto op = ud->GetUserData()->Get()->GetBinaryOperation(expression->GetOperatorKind(), boundRightType); + auto op = ud->GetUserData()->Get()->GetBinaryOperation(kind, boundRightType); if (op == nullptr){ - this->_scriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::NoBinaryOperationFound, - expression->GetStartPosition(), - expression->GetLength()); - return new BoundBadExpression(expression->GetStartPosition(), expression->GetLength()); + if (kind != BinaryOperatorKind::Equality && kind != BinaryOperatorKind::Inequality){ + this->_scriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::NoBinaryOperationFound, + expression->GetStartPosition(), + expression->GetLength()); + return new BoundBadExpression(expression->GetStartPosition(), expression->GetLength()); + } + } + else{ + return new BoundUserdataBinaryExpression(boundLeft, boundRight, op, op->GetReturnType(), + expression->GetStartPosition(), expression->GetLength()); } - return new BoundUserdataBinaryExpression(boundLeft, boundRight, op, op->GetReturnType(), - expression->GetStartPosition(), expression->GetLength()); } - switch (expression->GetOperatorKind()) { + switch (kind) { case BinaryOperatorKind::Addition: if (boundLeftType->GetClass() == TypeClass::Number && boundRightType->GetClass() == TypeClass::Number) { auto leftNumeric = std::static_pointer_cast(boundLeftType); diff --git a/src/UserData/UserDataScriptType.hpp b/src/UserData/UserDataScriptType.hpp index 4f727b1..cf64226 100644 --- a/src/UserData/UserDataScriptType.hpp +++ b/src/UserData/UserDataScriptType.hpp @@ -25,7 +25,7 @@ namespace Porygon::UserData { delete _userData; } - RetrievedUserData* GetUserData() const{ + [[nodiscard]] RetrievedUserData* GetUserData() const{ return _userData; } diff --git a/src/UserData/UserDataValue.hpp b/src/UserData/UserDataValue.hpp index 1f785cf..af2c386 100644 --- a/src/UserData/UserDataValue.hpp +++ b/src/UserData/UserDataValue.hpp @@ -22,7 +22,7 @@ namespace Porygon::UserData { _obj = obj; } - ~UserDataValue(){ + ~UserDataValue() final{ delete _userData; } @@ -74,7 +74,7 @@ namespace Porygon::UserData { delete value; } - inline void* GetObjectPointer() const{ + [[nodiscard]] inline void* GetObjectPointer() const{ return _obj; }