diff options
author | Christian <c@ethdev.com> | 2015-02-21 07:46:35 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2015-02-21 22:10:02 +0800 |
commit | be15e0b424d9a7bd181c8525dbb2eb0a26806c13 (patch) | |
tree | e8b2443b389f74a94b6dcfef9dc3854fc2a4670e /AST.cpp | |
parent | 5e3208317922d20a5b3b760df872a589d87bf94d (diff) | |
download | dexon-solidity-be15e0b424d9a7bd181c8525dbb2eb0a26806c13.tar.gz dexon-solidity-be15e0b424d9a7bd181c8525dbb2eb0a26806c13.tar.zst dexon-solidity-be15e0b424d9a7bd181c8525dbb2eb0a26806c13.zip |
Index access.
Diffstat (limited to 'AST.cpp')
-rw-r--r-- | AST.cpp | 29 |
1 files changed, 22 insertions, 7 deletions
@@ -609,13 +609,28 @@ void MemberAccess::checkTypeRequirements() void IndexAccess::checkTypeRequirements() { m_base->checkTypeRequirements(); - if (m_base->getType()->getCategory() != Type::Category::Mapping) - BOOST_THROW_EXCEPTION(m_base->createTypeError("Indexed expression has to be a mapping (is " + - m_base->getType()->toString() + ")")); - MappingType const& type = dynamic_cast<MappingType const&>(*m_base->getType()); - m_index->expectType(*type.getKeyType()); - m_type = type.getValueType(); - m_isLValue = true; + switch (m_base->getType()->getCategory()) + { + case Type::Category::Array: + { + ArrayType const& type = dynamic_cast<ArrayType const&>(*m_base->getType()); + m_index->expectType(IntegerType(256)); + m_type = type.getBaseType(); + m_isLValue = true; + break; + } + case Type::Category::Mapping: + { + MappingType const& type = dynamic_cast<MappingType const&>(*m_base->getType()); + m_index->expectType(*type.getKeyType()); + m_type = type.getValueType(); + m_isLValue = true; + break; + } + default: + BOOST_THROW_EXCEPTION(m_base->createTypeError( + "Indexed expression has to be a mapping or array (is " + m_base->getType()->toString() + ")")); + } } void Identifier::checkTypeRequirements() |