aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis/SyntaxChecker.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-04-18 20:28:53 +0800
committerchriseth <chris@ethereum.org>2018-04-19 03:23:09 +0800
commit489586430202d17fb60d973503ab27670474143d (patch)
treead708894de37ac9df7c6d7f8547ded8c990dc662 /libsolidity/analysis/SyntaxChecker.cpp
parentcd17c37fe6df143558a8aaadcec2495ff50f90df (diff)
downloaddexon-solidity-489586430202d17fb60d973503ab27670474143d.tar.gz
dexon-solidity-489586430202d17fb60d973503ab27670474143d.tar.zst
dexon-solidity-489586430202d17fb60d973503ab27670474143d.zip
Warn about functions named "constructor".
Diffstat (limited to 'libsolidity/analysis/SyntaxChecker.cpp')
-rw-r--r--libsolidity/analysis/SyntaxChecker.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/libsolidity/analysis/SyntaxChecker.cpp b/libsolidity/analysis/SyntaxChecker.cpp
index f648e5b4..396058f4 100644
--- a/libsolidity/analysis/SyntaxChecker.cpp
+++ b/libsolidity/analysis/SyntaxChecker.cpp
@@ -237,8 +237,13 @@ bool SyntaxChecker::visit(FunctionDefinition const& _function)
if (v050)
m_errorReporter.syntaxError(_function.location(), "Functions without implementation cannot have modifiers.");
else
- m_errorReporter.warning( _function.location(), "Modifiers of functions without implementation are ignored." );
+ 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;
}