mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Check if constructor is public or not.
This commit is contained in:
@@ -75,7 +75,10 @@ bool TypeChecker::visit(ContractDefinition const& _contract)
|
||||
checkContractAbstractConstructors(_contract);
|
||||
|
||||
FunctionDefinition const* function = _contract.constructor();
|
||||
if (function) {
|
||||
if (function)
|
||||
{
|
||||
if (!function->isPublic())
|
||||
_contract.annotation().hasPublicConstructor = false;
|
||||
if (!function->returnParameters().empty())
|
||||
typeError(function->returnParameterList()->location(), "Non-empty \"returns\" directive for constructor.");
|
||||
if (function->isDeclaredConst())
|
||||
@@ -1280,6 +1283,8 @@ void TypeChecker::endVisit(NewExpression const& _newExpression)
|
||||
fatalTypeError(_newExpression.location(), "Identifier is not a contract.");
|
||||
if (!contract->annotation().isFullyImplemented)
|
||||
typeError(_newExpression.location(), "Trying to create an instance of an abstract contract.");
|
||||
if (!contract->annotation().hasPublicConstructor)
|
||||
typeError(_newExpression.location(), "Contract with internal constructor cannot be created directly.");
|
||||
|
||||
solAssert(!!m_scope, "");
|
||||
m_scope->annotation().contractDependencies.insert(contract);
|
||||
|
||||
Reference in New Issue
Block a user