Skip to content

Commit

Permalink
Fix event parsing. Refs ethereum#3175
Browse files Browse the repository at this point in the history
  • Loading branch information
federicobond committed Nov 23, 2017
1 parent dc154b4 commit 14fd647
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Features:
* Type Checker: More detailed errors for invalid array lengths (such as division by zero).

Bugfixes:
* Parser: Disallow event declarations with no parameter list.

### 0.4.18 (2017-10-18)

Expand Down
14 changes: 5 additions & 9 deletions libsolidity/parsing/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,15 +644,11 @@ ASTPointer<EventDefinition> Parser::parseEventDefinition()

expectToken(Token::Event);
ASTPointer<ASTString> name(expectIdentifierToken());
ASTPointer<ParameterList> parameters;
if (m_scanner->currentToken() == Token::LParen)
{
VarDeclParserOptions options;
options.allowIndexed = true;
parameters = parseParameterList(options);
}
else
parameters = createEmptyParameterList();

VarDeclParserOptions options;
options.allowIndexed = true;
ASTPointer<ParameterList> parameters = parseParameterList(options);

bool anonymous = false;
if (m_scanner->currentToken() == Token::Anonymous)
{
Expand Down
6 changes: 3 additions & 3 deletions test/libsolidity/SolidityEndToEndTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2953,7 +2953,7 @@ BOOST_AUTO_TEST_CASE(event_no_arguments)
{
char const* sourceCode = R"(
contract ClientReceipt {
event Deposit;
event Deposit();
function deposit() {
Deposit();
}
Expand Down Expand Up @@ -2995,7 +2995,7 @@ BOOST_AUTO_TEST_CASE(events_with_same_name)
{
char const* sourceCode = R"(
contract ClientReceipt {
event Deposit;
event Deposit();
event Deposit(address _addr);
event Deposit(address _addr, uint _amount);
function deposit() returns (uint) {
Expand Down Expand Up @@ -3041,7 +3041,7 @@ BOOST_AUTO_TEST_CASE(events_with_same_name_inherited)
{
char const* sourceCode = R"(
contract A {
event Deposit;
event Deposit();
}
contract B {
Expand Down
10 changes: 10 additions & 0 deletions test/libsolidity/SolidityParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,16 @@ BOOST_AUTO_TEST_CASE(event_arguments_indexed)
BOOST_CHECK(successParse(text));
}

BOOST_AUTO_TEST_CASE(event_with_no_argument_list_fails)
{
char const* text = R"(
contract c {
event e;
}
)";
CHECK_PARSE_ERROR(text, "Expected token LParen got 'Semicolon'");
}

BOOST_AUTO_TEST_CASE(visibility_specifiers)
{
char const* text = R"(
Expand Down

0 comments on commit 14fd647

Please sign in to comment.