Use user defined function return type as user defined operator type

This commit is contained in:
wechman
2022-09-28 11:32:03 +02:00
parent 58d19a51c6
commit 6482f5bb17
4 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -1835,7 +1835,7 @@ void TypeChecker::endVisit(BinaryOperation const& _operation)
*userDefinedFunctionType->parameterTypes().at(0) ==
*userDefinedFunctionType->parameterTypes().at(1)
);
commonType = userDefinedFunctionType->parameterTypes().at(0);
commonType = userDefinedFunctionType->returnParameterTypes().at(0);
}
_operation.annotation().commonType = commonType;
@@ -775,7 +775,7 @@ bool IRGeneratorForStatements::visit(BinaryOperation const& _binOp)
{
setLocation(_binOp);
// TOOD make this nicer
// TODO: make this nicer
if (_binOp.annotation().userDefinedFunction)
{
_binOp.leftExpression().accept(*this);
+1 -1
View File
@@ -990,7 +990,7 @@ ASTPointer<UsingForDirective> Parser::parseUsingDirective()
};
if (!util::contains(overridable, operator_))
parserError(
1885_error,
4403_error,
("The operator " + string{TokenTraits::toString(operator_)} + " cannot be user-implemented. This is only possible for the following operators: ") +
util::joinHumanReadable(overridable | ranges::views::transform([](Token _t) { return string{TokenTraits::toString(_t)}; }))
);