Add missing checks for parameter compatibilty with ABIEncoderV1 in calls

This commit is contained in:
Kamil Śliwak
2020-10-06 21:28:46 +02:00
parent 25d408058b
commit 33ff79bf82
24 changed files with 503 additions and 0 deletions
+46
View File
@@ -2178,6 +2178,52 @@ void TypeChecker::typeCheckFunctionGeneralChecks(
m_errorReporter.typeError(errorId, paramArgMap[i]->location(), description);
}
}
TypePointers const& returnParameterTypes = _functionType->returnParameterTypes();
bool isLibraryCall = (_functionType->kind() == FunctionType::Kind::DelegateCall);
bool callRequiresABIEncoding =
// ABIEncode/ABIDecode calls not included because they should have been already validated
// at this point and they have variadic arguments so they need special handling.
_functionType->kind() == FunctionType::Kind::DelegateCall ||
_functionType->kind() == FunctionType::Kind::External ||
_functionType->kind() == FunctionType::Kind::Creation ||
_functionType->kind() == FunctionType::Kind::Event;
if (callRequiresABIEncoding && !experimentalFeatureActive(ExperimentalFeature::ABIEncoderV2))
{
solAssert(!isVariadic, "");
solAssert(parameterTypes.size() == arguments.size(), "");
solAssert(!_functionType->isBareCall(), "");
solAssert(*_functionCall.annotation().kind == FunctionCallKind::FunctionCall, "");
for (size_t i = 0; i < parameterTypes.size(); ++i)
{
solAssert(parameterTypes[i], "");
if (!typeSupportedByOldABIEncoder(*parameterTypes[i], isLibraryCall))
m_errorReporter.typeError(
2443_error,
paramArgMap[i]->location(),
"The type of this parameter, " + parameterTypes[i]->toString(true) + ", "
"is only supported in ABIEncoderV2. "
"Use \"pragma experimental ABIEncoderV2;\" to enable the feature."
);
}
for (size_t i = 0; i < returnParameterTypes.size(); ++i)
{
solAssert(returnParameterTypes[i], "");
if (!typeSupportedByOldABIEncoder(*returnParameterTypes[i], isLibraryCall))
m_errorReporter.typeError(
2428_error,
_functionCall.location(),
"The type of return parameter " + toString(i + 1) + ", " + returnParameterTypes[i]->toString(true) + ", "
"is only supported in ABIEncoderV2. "
"Use \"pragma experimental ABIEncoderV2;\" to enable the feature."
);
}
}
}
bool TypeChecker::visit(FunctionCall const& _functionCall)