diff options
author | chriseth <c@ethdev.com> | 2016-06-07 01:36:19 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2016-06-07 01:38:22 +0800 |
commit | ab7a22f4a0d95faacf453b76415eaee167aacdec (patch) | |
tree | 94a6f6ea9cffd3eaed15e8641b6fa3ae7523de60 | |
parent | a1aee031d1fd1b773c2184280625a00a6c84ae7d (diff) | |
download | dexon-solidity-ab7a22f4a0d95faacf453b76415eaee167aacdec.tar.gz dexon-solidity-ab7a22f4a0d95faacf453b76415eaee167aacdec.tar.zst dexon-solidity-ab7a22f4a0d95faacf453b76415eaee167aacdec.zip |
Disallow implementation of abstract function by constructor of derived class.
-rw-r--r-- | libsolidity/analysis/TypeChecker.cpp | 5 | ||||
-rw-r--r-- | libsolidity/codegen/ContractCompiler.cpp | 3 |
2 files changed, 7 insertions, 1 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 5ae0443a..ce55de00 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -32,7 +32,7 @@ using namespace dev; using namespace dev::solidity; -bool TypeChecker::checkTypeRequirements(const ContractDefinition& _contract) +bool TypeChecker::checkTypeRequirements(ContractDefinition const& _contract) { try { @@ -174,6 +174,9 @@ void TypeChecker::checkContractAbstractFunctions(ContractDefinition const& _cont for (ContractDefinition const* contract: boost::adaptors::reverse(_contract.annotation().linearizedBaseContracts)) for (FunctionDefinition const* function: contract->definedFunctions()) { + // Take constructors out of overload hierarchy + if (function->isConstructor()) + continue; auto& overloads = functions[function->name()]; FunctionTypePointer funType = make_shared<FunctionType>(*function); auto it = find_if(overloads.begin(), overloads.end(), [&](FunTypeAndFlag const& _funAndFlag) diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp index 3623046e..bcfd33f2 100644 --- a/libsolidity/codegen/ContractCompiler.cpp +++ b/libsolidity/codegen/ContractCompiler.cpp @@ -776,7 +776,10 @@ void ContractCompiler::appendModifierOrFunctionCode() { solAssert(m_currentFunction, ""); if (m_modifierDepth >= m_currentFunction->modifiers().size()) + { + solAssert(m_currentFunction->isImplemented(), ""); m_currentFunction->body().accept(*this); + } else { ASTPointer<ModifierInvocation> const& modifierInvocation = m_currentFunction->modifiers()[m_modifierDepth]; |