mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Index access.
This commit is contained in:
parent
5e32083179
commit
be15e0b424
21
AST.cpp
21
AST.cpp
@ -609,13 +609,28 @@ void MemberAccess::checkTypeRequirements()
|
|||||||
void IndexAccess::checkTypeRequirements()
|
void IndexAccess::checkTypeRequirements()
|
||||||
{
|
{
|
||||||
m_base->checkTypeRequirements();
|
m_base->checkTypeRequirements();
|
||||||
if (m_base->getType()->getCategory() != Type::Category::Mapping)
|
switch (m_base->getType()->getCategory())
|
||||||
BOOST_THROW_EXCEPTION(m_base->createTypeError("Indexed expression has to be a mapping (is " +
|
{
|
||||||
m_base->getType()->toString() + ")"));
|
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());
|
MappingType const& type = dynamic_cast<MappingType const&>(*m_base->getType());
|
||||||
m_index->expectType(*type.getKeyType());
|
m_index->expectType(*type.getKeyType());
|
||||||
m_type = type.getValueType();
|
m_type = type.getValueType();
|
||||||
m_isLValue = true;
|
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()
|
void Identifier::checkTypeRequirements()
|
||||||
|
Loading…
Reference in New Issue
Block a user