aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libsolidity/analysis/TypeChecker.cpp10
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp9
2 files changed, 14 insertions, 5 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index f70b75d3..99f3c64c 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -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(
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index a4fc9c98..f5f607ca 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -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()
}