mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Constructors are defined using the `constructor` keyword.
This commit is contained in:
committed by
Alex Beregszaszi
parent
0edce4b570
commit
d664a599e6
@@ -216,7 +216,22 @@ bool SyntaxChecker::visit(FunctionDefinition const& _function)
|
||||
|
||||
if (v050 && _function.noVisibilitySpecified())
|
||||
m_errorReporter.syntaxError(_function.location(), "No visibility specified.");
|
||||
|
||||
|
||||
if (_function.isOldStyleConstructor())
|
||||
{
|
||||
if (v050)
|
||||
m_errorReporter.syntaxError(
|
||||
_function.location(),
|
||||
"Functions are not allowed to have the same name as the contract. "
|
||||
"If you intend this to be a constructor, use \"constructor(...) { ... }\" to define it."
|
||||
);
|
||||
else
|
||||
m_errorReporter.warning(
|
||||
_function.location(),
|
||||
"Defining constructors as functions with the same name as the contract is deprecated. "
|
||||
"Use \"constructor(...) { ... }\" instead."
|
||||
);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user