aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis/SyntaxChecker.cpp
diff options
context:
space:
mode:
authorErik Kundt <bitshift@posteo.org>2018-06-27 18:29:03 +0800
committerErik Kundt <bitshift@posteo.org>2018-07-18 20:29:01 +0800
commit182a0a95516e4f218524b929035e6a1bd5d2742c (patch)
treebcf6743a43070346a5193f1a4d9d12c3b5bd092c /libsolidity/analysis/SyntaxChecker.cpp
parentb909df4573130e020c7f4dfb61c0571ba1bc02ab (diff)
downloaddexon-solidity-182a0a95516e4f218524b929035e6a1bd5d2742c.tar.gz
dexon-solidity-182a0a95516e4f218524b929035e6a1bd5d2742c.tar.zst
dexon-solidity-182a0a95516e4f218524b929035e6a1bd5d2742c.zip
Disallows old constructor syntax.
Diffstat (limited to 'libsolidity/analysis/SyntaxChecker.cpp')
-rw-r--r--libsolidity/analysis/SyntaxChecker.cpp28
1 files changed, 8 insertions, 20 deletions
diff --git a/libsolidity/analysis/SyntaxChecker.cpp b/libsolidity/analysis/SyntaxChecker.cpp
index 4d09e36d..5d16a33f 100644
--- a/libsolidity/analysis/SyntaxChecker.cpp
+++ b/libsolidity/analysis/SyntaxChecker.cpp
@@ -200,6 +200,14 @@ bool SyntaxChecker::visit(PlaceholderStatement const&)
bool SyntaxChecker::visit(ContractDefinition const& _contract)
{
m_isInterface = _contract.contractKind() == ContractDefinition::ContractKind::Interface;
+
+ ASTString const& contractName = _contract.name();
+ for (FunctionDefinition const* function: _contract.definedFunctions())
+ if (function->name() == contractName)
+ 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."
+ );
return true;
}
@@ -216,21 +224,6 @@ bool SyntaxChecker::visit(FunctionDefinition const& _function)
);
}
- 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."
- );
- }
if (!_function.isImplemented() && !_function.modifiers().empty())
{
if (v050)
@@ -238,11 +231,6 @@ bool SyntaxChecker::visit(FunctionDefinition const& _function)
else
m_errorReporter.warning(_function.location(), "Modifiers of functions without implementation are ignored." );
}
- if (_function.name() == "constructor")
- m_errorReporter.warning(_function.location(),
- "This function is named \"constructor\" but is not the constructor of the contract. "
- "If you intend this to be a constructor, use \"constructor(...) { ... }\" without the \"function\" keyword to define it."
- );
return true;
}