Rework error handlig of user type operators

This commit is contained in:
wechman
2022-09-28 13:07:58 +02:00
parent 4fac7b54b3
commit 6feb8aea73
10 changed files with 152 additions and 86 deletions
+9 -1
View File
@@ -404,8 +404,16 @@ Result<FunctionDefinition const*> Type::userDefinedOperator(Token _token, ASTNod
);
solAssert(functionType && !functionType->parameterTypes().empty());
Type const* normalizedType = this;
if (auto const* referenceType = dynamic_cast<ReferenceType const*>(normalizedType))
normalizedType = TypeProvider::withLocationIfReference(referenceType->location(), normalizedType);
Type const* normalizedParameterType = functionType->parameterTypes().front();
if (auto const* referenceType = dynamic_cast<ReferenceType const*>(normalizedParameterType))
normalizedParameterType = TypeProvider::withLocationIfReference(referenceType->location(), normalizedParameterType);
if (
isImplicitlyConvertibleTo(*functionType->parameterTypes().front()) &&
*normalizedType == *normalizedParameterType &&
(
(_unaryOperation && function.parameterList().parameters().size() == 1) ||
(!_unaryOperation && function.parameterList().parameters().size() == 2)