diff options
author | chriseth <chris@ethereum.org> | 2018-05-16 16:22:03 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-16 16:22:03 +0800 |
commit | 23adea88fdc7eafc5b67b759b4c2418bd6b93aa6 (patch) | |
tree | a648418931273de87ada16443d3c18b739c76d76 /libsolidity/analysis | |
parent | 54839fdffbc32f1f918790b1e09143a410bd1c80 (diff) | |
parent | 03f60410c9ad57c90a327ffb6e8b6b722ec9c995 (diff) | |
download | dexon-solidity-23adea88fdc7eafc5b67b759b4c2418bd6b93aa6.tar.gz dexon-solidity-23adea88fdc7eafc5b67b759b4c2418bd6b93aa6.tar.zst dexon-solidity-23adea88fdc7eafc5b67b759b4c2418bd6b93aa6.zip |
Merge pull request #4138 from ethereum/warnVarArgs
Warn when hash functions are used with var arguments
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r-- | libsolidity/analysis/TypeChecker.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index e8694e88..f77cc60c 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -1760,6 +1760,33 @@ 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 (v050) + m_errorReporter.typeError(_functionCall.location(), generalMessage); + else + m_errorReporter.warning(_functionCall.location(), generalMessage); + } + else if (arguments.size() == 1 && !type(*arguments.front())->isImplicitlyConvertibleTo(ArrayType(DataLocation::Memory))) + { + string msg = + generalMessage + + " The provided argument of type " + + type(*arguments.front())->toString() + + " is not implicitly convertible to expected type bytes memory."; + if (v050) + m_errorReporter.typeError(_functionCall.location(), msg); + else + m_errorReporter.warning(_functionCall.location(), msg); + } + } + if (functionType->takesArbitraryParameters() && arguments.size() < parameterTypes.size()) { solAssert(_functionCall.annotation().kind == FunctionCallKind::FunctionCall, ""); |