aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis
diff options
context:
space:
mode:
authorDaniel Kirchner <daniel@ekpyron.org>2018-03-02 01:39:01 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2018-04-04 00:21:55 +0800
commitd664a599e68291166c47fcece464cb8d0af31df8 (patch)
tree26668133eed7076b9d5a94d2a1f6ba982f79250e /libsolidity/analysis
parent0edce4b570c157927933697b30f0f94cbdf173b2 (diff)
downloaddexon-solidity-d664a599e68291166c47fcece464cb8d0af31df8.tar.gz
dexon-solidity-d664a599e68291166c47fcece464cb8d0af31df8.tar.zst
dexon-solidity-d664a599e68291166c47fcece464cb8d0af31df8.zip
Constructors are defined using the ``constructor`` keyword.
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r--libsolidity/analysis/SyntaxChecker.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/libsolidity/analysis/SyntaxChecker.cpp b/libsolidity/analysis/SyntaxChecker.cpp
index b595c4d1..343b4ba8 100644
--- a/libsolidity/analysis/SyntaxChecker.cpp
+++ b/libsolidity/analysis/SyntaxChecker.cpp
@@ -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;
}