mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Allow global enum definitions.
This commit is contained in:
parent
fae0e10d26
commit
2b938d703c
@ -99,8 +99,11 @@ ASTPointer<SourceUnit> Parser::parse(shared_ptr<Scanner> const& _scanner)
|
||||
case Token::Struct:
|
||||
nodes.push_back(parseStructDefinition());
|
||||
break;
|
||||
case Token::Enum:
|
||||
nodes.push_back(parseEnumDefinition());
|
||||
break;
|
||||
default:
|
||||
fatalParserError(string("Expected pragma, import directive or contract/interface/library/struct definition."));
|
||||
fatalParserError(string("Expected pragma, import directive or contract/interface/library/struct/enum definition."));
|
||||
}
|
||||
}
|
||||
solAssert(m_recursionDepth == 0, "");
|
||||
|
7
test/libsolidity/syntaxTests/enums/global_enum.sol
Normal file
7
test/libsolidity/syntaxTests/enums/global_enum.sol
Normal file
@ -0,0 +1,7 @@
|
||||
enum E { A }
|
||||
contract C {
|
||||
function f() public pure {
|
||||
E e = E.A;
|
||||
e;
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
enum E { A }
|
||||
contract E {}
|
||||
// ----
|
||||
// DeclarationError: (13-26): Identifier already declared.
|
@ -0,0 +1,4 @@
|
||||
enum E { A }
|
||||
enum E { A }
|
||||
// ----
|
||||
// DeclarationError: (13-25): Identifier already declared.
|
10
test/libsolidity/syntaxTests/enums/global_enum_shadowing.sol
Normal file
10
test/libsolidity/syntaxTests/enums/global_enum_shadowing.sol
Normal file
@ -0,0 +1,10 @@
|
||||
enum E { A }
|
||||
contract C {
|
||||
enum E { A }
|
||||
function f() public pure {
|
||||
E e = E.A;
|
||||
e;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (30-42): This declaration shadows an existing declaration.
|
@ -0,0 +1,7 @@
|
||||
==== Source: a ====
|
||||
enum E { A }
|
||||
==== Source: b ====
|
||||
import "a";
|
||||
enum E { A }
|
||||
// ----
|
||||
// DeclarationError: (b:12-24): Identifier already declared.
|
@ -0,0 +1,7 @@
|
||||
==== Source: a ====
|
||||
enum E { A }
|
||||
==== Source: b ====
|
||||
import "a";
|
||||
contract E { }
|
||||
// ----
|
||||
// DeclarationError: (b:12-26): Identifier already declared.
|
@ -0,0 +1,7 @@
|
||||
==== Source: a ====
|
||||
enum E { A }
|
||||
==== Source: b ====
|
||||
import "a";
|
||||
struct E { uint256 a; }
|
||||
// ----
|
||||
// DeclarationError: (b:12-35): Identifier already declared.
|
Loading…
Reference in New Issue
Block a user