aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/parsing
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-08-09 20:35:38 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-08-09 21:30:17 +0800
commitefd45f64a542c722d750f79b483dd7428aba16ed (patch)
tree9faffe22eb9c3fa3a20248e1d7550a1b7dfd1d32 /libsolidity/parsing
parenta8ca623a0f852c738b8bb92b449894ecc73b44e1 (diff)
downloaddexon-solidity-efd45f64a542c722d750f79b483dd7428aba16ed.tar.gz
dexon-solidity-efd45f64a542c722d750f79b483dd7428aba16ed.tar.zst
dexon-solidity-efd45f64a542c722d750f79b483dd7428aba16ed.zip
Show previous visibility specifier in parser error
Diffstat (limited to 'libsolidity/parsing')
-rw-r--r--libsolidity/parsing/Parser.cpp30
-rw-r--r--libsolidity/parsing/Parser.h1
2 files changed, 29 insertions, 2 deletions
diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp
index d1f9c1fa..7e1d36dd 100644
--- a/libsolidity/parsing/Parser.cpp
+++ b/libsolidity/parsing/Parser.cpp
@@ -307,6 +307,24 @@ Declaration::Visibility Parser::parseVisibilitySpecifier(Token::Value _token)
return visibility;
}
+string Parser::visibilitySpecifierName(Declaration::Visibility _visibility)
+{
+ switch(_visibility)
+ {
+ case Declaration::Visibility::Public:
+ return "public";
+ case Declaration::Visibility::Internal:
+ return "internal";
+ case Declaration::Visibility::Private:
+ return "private";
+ case Declaration::Visibility::External:
+ return "external";
+ default:
+ solAssert(false, "Invalid visibility specifier.");
+ }
+ return string();
+}
+
Parser::FunctionHeaderParserResult Parser::parseFunctionHeader(bool _forceEmptyName, bool _allowModifiers)
{
FunctionHeaderParserResult result;
@@ -354,7 +372,11 @@ Parser::FunctionHeaderParserResult Parser::parseFunctionHeader(bool _forceEmptyN
{
if (result.visibility != Declaration::Visibility::Default)
{
- parserError(string("Visibility already specified."));
+ parserError(string(
+ "Visibility already specified as \"" +
+ visibilitySpecifierName(result.visibility) +
+ "\"."
+ ));
m_scanner->next();
}
else
@@ -512,7 +534,11 @@ ASTPointer<VariableDeclaration> Parser::parseVariableDeclaration(
{
if (visibility != Declaration::Visibility::Default)
{
- parserError(string("Visibility already specified."));
+ parserError(string(
+ "Visibility already specified as \"" +
+ visibilitySpecifierName(visibility) +
+ "\"."
+ ));
m_scanner->next();
}
else
diff --git a/libsolidity/parsing/Parser.h b/libsolidity/parsing/Parser.h
index 19631c58..82ab91a6 100644
--- a/libsolidity/parsing/Parser.h
+++ b/libsolidity/parsing/Parser.h
@@ -73,6 +73,7 @@ private:
ASTPointer<ContractDefinition> parseContractDefinition(Token::Value _expectedKind);
ASTPointer<InheritanceSpecifier> parseInheritanceSpecifier();
Declaration::Visibility parseVisibilitySpecifier(Token::Value _token);
+ std::string visibilitySpecifierName(Declaration::Visibility _visibility);
FunctionHeaderParserResult parseFunctionHeader(bool _forceEmptyName, bool _allowModifiers);
ASTPointer<ASTNode> parseFunctionDefinitionOrFunctionTypeStateVariable(ASTString const* _contractName);
ASTPointer<FunctionDefinition> parseFunctionDefinition(ASTString const* _contractName);