diff options
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/analysis/TypeChecker.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index f77cc60c..30302908 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -1762,22 +1762,24 @@ bool TypeChecker::visit(FunctionCall const& _functionCall) if (functionType->takesSinglePackedBytesParameter()) { - string generalMessage = - "This function only accepts a single \"bytes\" argument. Please use " - "\"abi.encodePacked(...)\" or a similar function to encode the data."; - - if (arguments.size() > 1) + if ( + (arguments.size() > 1) || + (arguments.size() == 1 && !type(*arguments.front())->isImplicitlyConvertibleTo(ArrayType(DataLocation::Memory))) + ) { + string msg = + "This function only accepts a single \"bytes\" argument. Please use " + "\"abi.encodePacked(...)\" or a similar function to encode the data."; if (v050) - m_errorReporter.typeError(_functionCall.location(), generalMessage); + m_errorReporter.typeError(_functionCall.location(), msg); else - m_errorReporter.warning(_functionCall.location(), generalMessage); + m_errorReporter.warning(_functionCall.location(), msg); } - else if (arguments.size() == 1 && !type(*arguments.front())->isImplicitlyConvertibleTo(ArrayType(DataLocation::Memory))) + + if (arguments.size() == 1 && !type(*arguments.front())->isImplicitlyConvertibleTo(ArrayType(DataLocation::Memory))) { string msg = - generalMessage + - " The provided argument of type " + + "The provided argument of type " + type(*arguments.front())->toString() + " is not implicitly convertible to expected type bytes memory."; if (v050) |