diff options
author | chriseth <chris@ethereum.org> | 2018-07-13 01:22:38 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-13 01:22:38 +0800 |
commit | 5d8a8f726555361a78dac05a5413558f3f63f7f1 (patch) | |
tree | 6b8087793be20959f8f16f17e5683b90e5841e12 /libsolidity/analysis/SyntaxChecker.cpp | |
parent | 6dcafac44e1dc6b6b75b61c65b3f55c4f2af8575 (diff) | |
parent | cc585138bc08ff421a026d08f07020b284d946ce (diff) | |
download | dexon-solidity-5d8a8f726555361a78dac05a5413558f3f63f7f1.tar.gz dexon-solidity-5d8a8f726555361a78dac05a5413558f3f63f7f1.tar.zst dexon-solidity-5d8a8f726555361a78dac05a5413558f3f63f7f1.zip |
Merge pull request #4437 from ethereum/report-empty-var-decls
[BREAKING] Report empty var tuple decls
Diffstat (limited to 'libsolidity/analysis/SyntaxChecker.cpp')
-rw-r--r-- | libsolidity/analysis/SyntaxChecker.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libsolidity/analysis/SyntaxChecker.cpp b/libsolidity/analysis/SyntaxChecker.cpp index 4311e77d..e33aafed 100644 --- a/libsolidity/analysis/SyntaxChecker.cpp +++ b/libsolidity/analysis/SyntaxChecker.cpp @@ -22,6 +22,7 @@ #include <libsolidity/analysis/SemVerHandler.h> #include <libsolidity/interface/ErrorReporter.h> #include <libsolidity/interface/Version.h> +#include <boost/algorithm/cxx11/all_of.hpp> using namespace std; using namespace dev; @@ -254,6 +255,18 @@ bool SyntaxChecker::visit(FunctionTypeName const& _node) return true; } +bool SyntaxChecker::visit(VariableDeclarationStatement const& _statement) +{ + // Report if none of the variable components in the tuple have a name (only possible via deprecated "var") + if (boost::algorithm::all_of_equal(_statement.declarations(), nullptr)) + m_errorReporter.syntaxError( + _statement.location(), + "The use of the \"var\" keyword is disallowed. The declaration part of the statement can be removed, since it is empty." + ); + + return true; +} + bool SyntaxChecker::visit(StructDefinition const& _struct) { if (_struct.members().empty()) |