diff options
author | Lefteris Karapetsas <lefteris@refu.co> | 2015-02-13 20:32:18 +0800 |
---|---|---|
committer | Lefteris Karapetsas <lefteris@refu.co> | 2015-02-14 06:16:14 +0800 |
commit | 91943e736854d764811d8633f9e0f0187fe927e2 (patch) | |
tree | 8738aa5bdfdbabc9a1d3fbb4d40c95f2a35ff62a /AST.cpp | |
parent | 012e32942df6ef7e48ebf0735eca2cd8fe062af0 (diff) | |
download | dexon-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.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -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 |