mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Check inheritance specifier arguments for interfaces.
This commit is contained in:
parent
b25f0c52ac
commit
7b0046a9aa
@ -429,12 +429,12 @@ void TypeChecker::endVisit(InheritanceSpecifier const& _inheritance)
|
||||
if (base->isLibrary())
|
||||
m_errorReporter.typeError(_inheritance.location(), "Libraries cannot be inherited from.");
|
||||
|
||||
// Interface can have no constructors - no need to validate
|
||||
if (base->contractKind() == ContractDefinition::ContractKind::Interface)
|
||||
return;
|
||||
|
||||
auto const& arguments = _inheritance.arguments();
|
||||
TypePointers parameterTypes = ContractType(*base).newExpressionType()->parameterTypes();
|
||||
TypePointers parameterTypes;
|
||||
if (base->contractKind() != ContractDefinition::ContractKind::Interface)
|
||||
// Interfaces do not have constructors, so there are zero parameters.
|
||||
parameterTypes = ContractType(*base).newExpressionType()->parameterTypes();
|
||||
|
||||
if (!arguments.empty() && parameterTypes.size() != arguments.size())
|
||||
{
|
||||
m_errorReporter.typeError(
|
||||
|
@ -6735,6 +6735,15 @@ BOOST_AUTO_TEST_CASE(accept_library_creation)
|
||||
CHECK_SUCCESS(text);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(reject_interface_constructors)
|
||||
{
|
||||
char const* text = R"(
|
||||
interface I {}
|
||||
contract C is I(2) {}
|
||||
)";
|
||||
CHECK_ERROR(text, TypeError, "Wrong argument count for constructor call: 1 arguments given but expected 0.");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user