aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYoichi Hirai <i@yoichihirai.com>2017-12-12 18:12:18 +0800
committerGitHub <noreply@github.com>2017-12-12 18:12:18 +0800
commit14707b27e23a640274ce507c1c9a3d862f2c2b7f (patch)
tree762a58a830d3fd77bcf3032f5df3d91c827b01be
parenta0e67dec4683346becf4c864b3c7b7c4ab90bb71 (diff)
parent14fd647b852146cd885426d04bffffbd1b7c08a0 (diff)
downloaddexon-solidity-14707b27e23a640274ce507c1c9a3d862f2c2b7f.tar
dexon-solidity-14707b27e23a640274ce507c1c9a3d862f2c2b7f.tar.gz
dexon-solidity-14707b27e23a640274ce507c1c9a3d862f2c2b7f.tar.bz2
dexon-solidity-14707b27e23a640274ce507c1c9a3d862f2c2b7f.tar.lz
dexon-solidity-14707b27e23a640274ce507c1c9a3d862f2c2b7f.tar.xz
dexon-solidity-14707b27e23a640274ce507c1c9a3d862f2c2b7f.tar.zst
dexon-solidity-14707b27e23a640274ce507c1c9a3d862f2c2b7f.zip
Merge pull request #3183 from federicobond/fix-event-parsing
Fix event parsing. Refs #3175
-rw-r--r--Changelog.md1
-rw-r--r--libsolidity/parsing/Parser.cpp14
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp6
-rw-r--r--test/libsolidity/SolidityParser.cpp10
4 files changed, 19 insertions, 12 deletions
diff --git a/Changelog.md b/Changelog.md
index cf6498a1..4cd83eeb 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -20,6 +20,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)
diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp
index 821e81d2..05b877b5 100644
--- a/libsolidity/parsing/Parser.cpp
+++ b/libsolidity/parsing/Parser.cpp
@@ -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)
{
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 05dc9ba3..f5f7e64a 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -2971,7 +2971,7 @@ BOOST_AUTO_TEST_CASE(event_no_arguments)
{
char const* sourceCode = R"(
contract ClientReceipt {
- event Deposit;
+ event Deposit();
function deposit() {
Deposit();
}
@@ -3013,7 +3013,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) {
@@ -3059,7 +3059,7 @@ BOOST_AUTO_TEST_CASE(events_with_same_name_inherited)
{
char const* sourceCode = R"(
contract A {
- event Deposit;
+ event Deposit();
}
contract B {
diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp
index 72473c3e..861e6408 100644
--- a/test/libsolidity/SolidityParser.cpp
+++ b/test/libsolidity/SolidityParser.cpp
@@ -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"(