Browse Source

Removing ';' from the end of EnumDefinition

cl-refactor
Lefteris Karapetsas 10 years ago
parent
commit
c3c52d59b2
  1. 1
      libsolidity/Parser.cpp
  2. 2
      libsolidity/grammar.txt
  3. 2
      test/SolidityEndToEndTest.cpp
  4. 12
      test/SolidityNameAndTypeResolution.cpp
  5. 6
      test/SolidityParser.cpp

1
libsolidity/Parser.cpp

@ -293,7 +293,6 @@ ASTPointer<EnumDefinition> Parser::parseEnumDefinition()
nodeFactory.markEndPosition(); nodeFactory.markEndPosition();
expectToken(Token::RBrace); expectToken(Token::RBrace);
expectToken(Token::Semicolon);
return nodeFactory.createNode<EnumDefinition>(name, members); return nodeFactory.createNode<EnumDefinition>(name, members);
} }

2
libsolidity/grammar.txt

@ -13,7 +13,7 @@ FunctionDefinition = 'function' Identifier ParameterList
( 'returns' ParameterList )? Block ( 'returns' ParameterList )? Block
EnumValue = Identifier EnumValue = Identifier
EnumDefinition = 'enum' '{' EnumValue (',' EnumValue)* '}' ';' EnumDefinition = 'enum' '{' EnumValue (',' EnumValue)* '}'
ParameterList = '(' ( VariableDeclaration (',' VariableDeclaration)* )? ')' ParameterList = '(' ( VariableDeclaration (',' VariableDeclaration)* )? ')'
// semantic restriction: mappings and structs (recursively) containing mappings // semantic restriction: mappings and structs (recursively) containing mappings
// are not allowed in argument lists // are not allowed in argument lists

2
test/SolidityEndToEndTest.cpp

@ -2503,7 +2503,7 @@ BOOST_AUTO_TEST_CASE(using_enums)
{ {
char const* sourceCode = R"( char const* sourceCode = R"(
contract test { contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }; enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
function test() function test()
{ {
choices = ActionChoices.GoStraight; choices = ActionChoices.GoStraight;

12
test/SolidityNameAndTypeResolution.cpp

@ -996,7 +996,7 @@ BOOST_AUTO_TEST_CASE(enum_member_access)
{ {
char const* text = R"( char const* text = R"(
contract test { contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }; enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
function test() function test()
{ {
choices = ActionChoices.GoStraight; choices = ActionChoices.GoStraight;
@ -1011,7 +1011,7 @@ BOOST_AUTO_TEST_CASE(enum_invalid_member_access)
{ {
char const* text = R"( char const* text = R"(
contract test { contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }; enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
function test() function test()
{ {
choices = ActionChoices.RunAroundWavingYourHands; choices = ActionChoices.RunAroundWavingYourHands;
@ -1026,7 +1026,7 @@ BOOST_AUTO_TEST_CASE(enum_explicit_conversion_is_okay)
{ {
char const* text = R"( char const* text = R"(
contract test { contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }; enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
function test() function test()
{ {
a = uint256(ActionChoices.GoStraight); a = uint256(ActionChoices.GoStraight);
@ -1043,7 +1043,7 @@ BOOST_AUTO_TEST_CASE(int_to_enum_explicit_conversion_is_okay)
{ {
char const* text = R"( char const* text = R"(
contract test { contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }; enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
function test() function test()
{ {
a = 2; a = 2;
@ -1060,7 +1060,7 @@ BOOST_AUTO_TEST_CASE(enum_implicit_conversion_is_not_okay)
{ {
char const* text = R"( char const* text = R"(
contract test { contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }; enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
function test() function test()
{ {
a = ActionChoices.GoStraight; a = ActionChoices.GoStraight;
@ -1077,7 +1077,7 @@ BOOST_AUTO_TEST_CASE(enum_duplicate_values)
{ {
char const* text = R"( char const* text = R"(
contract test { contract test {
enum ActionChoices { GoLeft, GoRight, GoLeft, Sit }; enum ActionChoices { GoLeft, GoRight, GoLeft, Sit }
} }
)"; )";
BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError); BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);

6
test/SolidityParser.cpp

@ -707,7 +707,7 @@ BOOST_AUTO_TEST_CASE(enum_valid_declaration)
{ {
char const* text = R"( char const* text = R"(
contract c { contract c {
enum validEnum { Value1, Value2, Value3, Value4 }; enum validEnum { Value1, Value2, Value3, Value4 }
function c () function c ()
{ {
a = foo.Value3; a = foo.Value3;
@ -721,7 +721,7 @@ BOOST_AUTO_TEST_CASE(empty_enum_declaration)
{ {
char const* text = R"( char const* text = R"(
contract c { contract c {
enum foo { }; enum foo { }
})"; })";
BOOST_CHECK_NO_THROW(parseTextExplainError(text)); BOOST_CHECK_NO_THROW(parseTextExplainError(text));
} }
@ -730,7 +730,7 @@ BOOST_AUTO_TEST_CASE(malformed_enum_declaration)
{ {
char const* text = R"( char const* text = R"(
contract c { contract c {
enum foo { WARNING,}; enum foo { WARNING,}
})"; })";
BOOST_CHECK_THROW(parseText(text), ParserError); BOOST_CHECK_THROW(parseText(text), ParserError);
} }

Loading…
Cancel
Save