From 221a4d1f1f8a644ef9905f8f1d4a9a4428ec0489 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 16 May 2018 11:12:25 +0200 Subject: Split warning for multi arguments for hash functions --- libsolidity/analysis/TypeChecker.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'libsolidity') 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) -- cgit v1.2.3