mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Generates a syntax error when declaring a variable declaration's LHS has no named components
This commit is contained in:
committed by
chriseth
parent
fa8102880f
commit
cc585138bc
@@ -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())
|
||||
|
||||
@@ -69,6 +69,8 @@ private:
|
||||
virtual bool visit(FunctionDefinition const& _function) override;
|
||||
virtual bool visit(FunctionTypeName const& _node) override;
|
||||
|
||||
virtual bool visit(VariableDeclarationStatement const& _statement) override;
|
||||
|
||||
virtual bool visit(StructDefinition const& _struct) override;
|
||||
|
||||
ErrorReporter& m_errorReporter;
|
||||
|
||||
Reference in New Issue
Block a user