Constructors are defined using the `constructor` keyword.

This commit is contained in:
Daniel Kirchner
2018-04-03 18:21:55 +02:00
committed by Alex Beregszaszi
parent 0edce4b570
commit d664a599e6
8 changed files with 80 additions and 13 deletions
+16 -1
View File
@@ -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;
}