aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-03-22 02:07:15 +0800
committerchriseth <chris@ethereum.org>2018-04-12 06:10:25 +0800
commit7343c4028365d3fbc9fa46fca6078971a2bed426 (patch)
tree3044d8ea9bb6434f660305313002ad023f9ba185 /libsolidity/analysis
parentc4a6a63f362f478414ac886ed6e5e159038460aa (diff)
downloaddexon-solidity-7343c4028365d3fbc9fa46fca6078971a2bed426.tar.gz
dexon-solidity-7343c4028365d3fbc9fa46fca6078971a2bed426.tar.zst
dexon-solidity-7343c4028365d3fbc9fa46fca6078971a2bed426.zip
Check partial function parameters if rest is arbitrary.
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r--libsolidity/analysis/TypeChecker.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 8b57fc15..df08598c 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -1688,7 +1688,19 @@ bool TypeChecker::visit(FunctionCall const& _functionCall)
}
}
- if (!functionType->takesArbitraryParameters() && parameterTypes.size() != arguments.size())
+ if (functionType->takesArbitraryParameters() && arguments.size() < parameterTypes.size())
+ {
+ solAssert(_functionCall.annotation().kind == FunctionCallKind::FunctionCall, "");
+ m_errorReporter.typeError(
+ _functionCall.location(),
+ "Need at least " +
+ toString(parameterTypes.size()) +
+ " arguments for function call, but provided only " +
+ toString(arguments.size()) +
+ "."
+ );
+ }
+ else if (!functionType->takesArbitraryParameters() && parameterTypes.size() != arguments.size())
{
bool isStructConstructorCall = _functionCall.annotation().kind == FunctionCallKind::StructConstructorCall;
@@ -1711,11 +1723,10 @@ bool TypeChecker::visit(FunctionCall const& _functionCall)
}
else if (isPositionalCall)
{
- // call by positional arguments
for (size_t i = 0; i < arguments.size(); ++i)
{
auto const& argType = type(*arguments[i]);
- if (functionType->takesArbitraryParameters())
+ if (functionType->takesArbitraryParameters() && i >= parameterTypes.size())
{
bool errored = false;
if (auto t = dynamic_cast<RationalNumberType const*>(argType.get()))