Disallow implementation of abstract function by constructor of derived class.

This commit is contained in:
chriseth 2016-06-06 19:36:19 +02:00
parent a1aee031d1
commit ab7a22f4a0
2 changed files with 7 additions and 1 deletions

View File

@ -32,7 +32,7 @@ using namespace dev;
using namespace dev::solidity; using namespace dev::solidity;
bool TypeChecker::checkTypeRequirements(const ContractDefinition& _contract) bool TypeChecker::checkTypeRequirements(ContractDefinition const& _contract)
{ {
try try
{ {
@ -174,6 +174,9 @@ void TypeChecker::checkContractAbstractFunctions(ContractDefinition const& _cont
for (ContractDefinition const* contract: boost::adaptors::reverse(_contract.annotation().linearizedBaseContracts)) for (ContractDefinition const* contract: boost::adaptors::reverse(_contract.annotation().linearizedBaseContracts))
for (FunctionDefinition const* function: contract->definedFunctions()) for (FunctionDefinition const* function: contract->definedFunctions())
{ {
// Take constructors out of overload hierarchy
if (function->isConstructor())
continue;
auto& overloads = functions[function->name()]; auto& overloads = functions[function->name()];
FunctionTypePointer funType = make_shared<FunctionType>(*function); FunctionTypePointer funType = make_shared<FunctionType>(*function);
auto it = find_if(overloads.begin(), overloads.end(), [&](FunTypeAndFlag const& _funAndFlag) auto it = find_if(overloads.begin(), overloads.end(), [&](FunTypeAndFlag const& _funAndFlag)

View File

@ -776,7 +776,10 @@ void ContractCompiler::appendModifierOrFunctionCode()
{ {
solAssert(m_currentFunction, ""); solAssert(m_currentFunction, "");
if (m_modifierDepth >= m_currentFunction->modifiers().size()) if (m_modifierDepth >= m_currentFunction->modifiers().size())
{
solAssert(m_currentFunction->isImplemented(), "");
m_currentFunction->body().accept(*this); m_currentFunction->body().accept(*this);
}
else else
{ {
ASTPointer<ModifierInvocation> const& modifierInvocation = m_currentFunction->modifiers()[m_modifierDepth]; ASTPointer<ModifierInvocation> const& modifierInvocation = m_currentFunction->modifiers()[m_modifierDepth];