aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-06-14 22:08:59 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2018-06-25 23:17:48 +0800
commit5cf6fa84ace58e9fa0fef2a7fc40e531c56acb24 (patch)
tree170f48ee560c67b46c4e86a3c6aaa22ee75b18cb /libsolidity/analysis
parente299a0031f6519cecdf88eeeeff59a9eb02b6168 (diff)
downloaddexon-solidity-5cf6fa84ace58e9fa0fef2a7fc40e531c56acb24.tar.gz
dexon-solidity-5cf6fa84ace58e9fa0fef2a7fc40e531c56acb24.tar.zst
dexon-solidity-5cf6fa84ace58e9fa0fef2a7fc40e531c56acb24.zip
Provide better suggestions in error messages with respect to call and hash functions.
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r--libsolidity/analysis/TypeChecker.cpp38
1 files changed, 34 insertions, 4 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index ab6b46f4..9c4e9021 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -1781,6 +1781,23 @@ bool TypeChecker::visit(FunctionCall const& _functionCall)
for (auto const& member: membersRemovedForStructConstructor)
msg += " " + member;
}
+ else if (
+ functionType->kind() == FunctionType::Kind::BareCall ||
+ functionType->kind() == FunctionType::Kind::BareCallCode ||
+ functionType->kind() == FunctionType::Kind::BareDelegateCall
+ )
+ {
+ if (arguments.empty())
+ msg += " This function requires a single bytes argument. Use \"\" as argument to provide empty calldata.";
+ else
+ msg += " This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it.";
+ }
+ else if (
+ functionType->kind() == FunctionType::Kind::SHA3 ||
+ functionType->kind() == FunctionType::Kind::SHA256 ||
+ functionType->kind() == FunctionType::Kind::RIPEMD160
+ )
+ msg += " This function requires a single bytes argument. Use abi.encodePacked(...) to properly encode the values.";
m_errorReporter.typeError(_functionCall.location(), msg);
}
else if (isPositionalCall)
@@ -1817,15 +1834,28 @@ bool TypeChecker::visit(FunctionCall const& _functionCall)
}
}
else if (!type(*arguments[i])->isImplicitlyConvertibleTo(*parameterTypes[i]))
- m_errorReporter.typeError(
- arguments[i]->location(),
+ {
+ string msg =
"Invalid type for argument in function call. "
"Invalid implicit conversion from " +
type(*arguments[i])->toString() +
" to " +
parameterTypes[i]->toString() +
- " requested."
- );
+ " requested.";
+ if (
+ functionType->kind() == FunctionType::Kind::BareCall ||
+ functionType->kind() == FunctionType::Kind::BareCallCode ||
+ functionType->kind() == FunctionType::Kind::BareDelegateCall
+ )
+ msg += " This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it.";
+ else if (
+ functionType->kind() == FunctionType::Kind::SHA3 ||
+ functionType->kind() == FunctionType::Kind::SHA256 ||
+ functionType->kind() == FunctionType::Kind::RIPEMD160
+ )
+ msg += " This function requires a single bytes argument. Use abi.encodePacked(...) to properly encode the values.";
+ m_errorReporter.typeError(arguments[i]->location(), msg);
+ }
}
}
else