aboutsummaryrefslogtreecommitdiffstats
path: root/AST.cpp
diff options
context:
space:
mode:
authorLefteris Karapetsas <lefteris@refu.co>2015-02-13 20:32:18 +0800
committerLefteris Karapetsas <lefteris@refu.co>2015-02-14 06:16:14 +0800
commit91943e736854d764811d8633f9e0f0187fe927e2 (patch)
tree8738aa5bdfdbabc9a1d3fbb4d40c95f2a35ff62a /AST.cpp
parent012e32942df6ef7e48ebf0735eca2cd8fe062af0 (diff)
downloaddexon-solidity-91943e736854d764811d8633f9e0f0187fe927e2.tar.gz
dexon-solidity-91943e736854d764811d8633f9e0f0187fe927e2.tar.zst
dexon-solidity-91943e736854d764811d8633f9e0f0187fe927e2.zip
Enum Value member access should now work properly
- Also detection of duplicate enum values and tests for them have been added
Diffstat (limited to 'AST.cpp')
-rw-r--r--AST.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/AST.cpp b/AST.cpp
index 7653952f..65dc57e5 100644
--- a/AST.cpp
+++ b/AST.cpp
@@ -263,13 +263,15 @@ void StructDefinition::checkRecursion() const
void EnumDefinition::checkValidityOfMembers() const
{
-#if 0 // LTODO: Make this work for the Declarations
- vector<ASTPointer<ASTString>> members = getMembers();
- sort(begin(members), end(members));
- for (size_t i = 0; i < members.size(); ++i)
- if (members[i] == members[i + 1])
+ vector<ASTPointer<EnumDeclaration>> members(getMembers());
+ auto compareDecls = [](ASTPointer<EnumDeclaration> a, ASTPointer<EnumDeclaration> b)
+ {
+ return a->getName() < b->getName();
+ };
+ sort(begin(members), end(members), compareDecls);
+ for (size_t i = 0; i < members.size() - 1; ++i)
+ if (members[i]->getName() == members[i + 1]->getName())
BOOST_THROW_EXCEPTION(createTypeError("Duplicate member detected in Enum"));
-#endif
}
TypePointer EnumDefinition::getType(ContractDefinition const*) const