diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 21d391b80..987ad1177 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -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; diff --git a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp index 6bcd6ab9c..61e70f257 100644 --- a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp +++ b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp @@ -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); diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp index 6f71de48c..b1569fa76 100644 --- a/libsolidity/parsing/Parser.cpp +++ b/libsolidity/parsing/Parser.cpp @@ -990,7 +990,7 @@ ASTPointer 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)}; })) ); diff --git a/test/libsolidity/syntaxTests/operators/custom/operator_not_user_implemented.sol b/test/libsolidity/syntaxTests/operators/custom/operator_not_user_implemented.sol index e5db8ee7d..499b3c5af 100644 --- a/test/libsolidity/syntaxTests/operators/custom/operator_not_user_implemented.sol +++ b/test/libsolidity/syntaxTests/operators/custom/operator_not_user_implemented.sol @@ -4,7 +4,7 @@ using { } for int256; // ---- -// ParserError 1885: (22-24): The operator << cannot be user-implemented. This is only possible for the following operators: |, &, ^, +, -, *, /, %, ==, !=, <, >, <=, >=, ~ -// ParserError 1885: (36-38): The operator >> cannot be user-implemented. This is only possible for the following operators: |, &, ^, +, -, *, /, %, ==, !=, <, >, <=, >=, ~ -// ParserError 1885: (51-53): The operator ** cannot be user-implemented. This is only possible for the following operators: |, &, ^, +, -, *, /, %, ==, !=, <, >, <=, >=, ~ -// ParserError 1885: (62-63): The operator ! cannot be user-implemented. This is only possible for the following operators: |, &, ^, +, -, *, /, %, ==, !=, <, >, <=, >=, ~ +// ParserError 4403: (22-24): The operator << cannot be user-implemented. This is only possible for the following operators: |, &, ^, +, -, *, /, %, ==, !=, <, >, <=, >=, ~ +// ParserError 4403: (36-38): The operator >> cannot be user-implemented. This is only possible for the following operators: |, &, ^, +, -, *, /, %, ==, !=, <, >, <=, >=, ~ +// ParserError 4403: (51-53): The operator ** cannot be user-implemented. This is only possible for the following operators: |, &, ^, +, -, *, /, %, ==, !=, <, >, <=, >=, ~ +// ParserError 4403: (62-63): The operator ! cannot be user-implemented. This is only possible for the following operators: |, &, ^, +, -, *, /, %, ==, !=, <, >, <=, >=, ~