mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Move constructor checks.
This commit is contained in:
parent
b610be4882
commit
2a85152463
@ -40,6 +40,7 @@ bool ContractLevelChecker::check(ContractDefinition const& _contract)
|
||||
checkIllegalOverrides(_contract);
|
||||
checkAbstractFunctions(_contract);
|
||||
checkBaseConstructorArguments(_contract);
|
||||
checkConstructor(_contract);
|
||||
|
||||
return Error::containsOnlyWarnings(m_errorReporter.errors());
|
||||
}
|
||||
@ -339,3 +340,22 @@ void ContractLevelChecker::annotateBaseConstructorArguments(
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ContractLevelChecker::checkConstructor(ContractDefinition const& _contract)
|
||||
{
|
||||
FunctionDefinition const* constructor = _contract.constructor();
|
||||
if (!constructor)
|
||||
return;
|
||||
|
||||
if (!constructor->returnParameters().empty())
|
||||
m_errorReporter.typeError(constructor->returnParameterList()->location(), "Non-empty \"returns\" directive for constructor.");
|
||||
if (constructor->stateMutability() != StateMutability::NonPayable && constructor->stateMutability() != StateMutability::Payable)
|
||||
m_errorReporter.typeError(
|
||||
constructor->location(),
|
||||
"Constructor must be payable or non-payable, but is \"" +
|
||||
stateMutabilityToString(constructor->stateMutability()) +
|
||||
"\"."
|
||||
);
|
||||
if (constructor->visibility() != FunctionDefinition::Visibility::Public && constructor->visibility() != FunctionDefinition::Visibility::Internal)
|
||||
m_errorReporter.typeError(constructor->location(), "Constructor must be public or internal.");
|
||||
}
|
||||
|
@ -70,6 +70,7 @@ private:
|
||||
FunctionDefinition const* _baseConstructor,
|
||||
ASTNode const* _argumentNode
|
||||
);
|
||||
void checkConstructor(ContractDefinition const& _contract);
|
||||
|
||||
langutil::ErrorReporter& m_errorReporter;
|
||||
};
|
||||
|
@ -90,22 +90,6 @@ bool TypeChecker::visit(ContractDefinition const& _contract)
|
||||
|
||||
ASTNode::listAccept(_contract.baseContracts(), *this);
|
||||
|
||||
FunctionDefinition const* function = _contract.constructor();
|
||||
if (function)
|
||||
{
|
||||
if (!function->returnParameters().empty())
|
||||
m_errorReporter.typeError(function->returnParameterList()->location(), "Non-empty \"returns\" directive for constructor.");
|
||||
if (function->stateMutability() != StateMutability::NonPayable && function->stateMutability() != StateMutability::Payable)
|
||||
m_errorReporter.typeError(
|
||||
function->location(),
|
||||
"Constructor must be payable or non-payable, but is \"" +
|
||||
stateMutabilityToString(function->stateMutability()) +
|
||||
"\"."
|
||||
);
|
||||
if (function->visibility() != FunctionDefinition::Visibility::Public && function->visibility() != FunctionDefinition::Visibility::Internal)
|
||||
m_errorReporter.typeError(function->location(), "Constructor must be public or internal.");
|
||||
}
|
||||
|
||||
for (FunctionDefinition const* function: _contract.definedFunctions())
|
||||
if (function->isFallback())
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user