mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Index access for bytesXX.
This commit is contained in:
1 parent
fad2d4df22
commit
29faf1b298
6 files changed
+99
No files matched your search
@@ -1253,6 +1253,8 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess)
|
||||
arrayType.isDynamicallySized()
|
||||
);
|
||||
}
|
||||
else if (exprType->category() == Type::Category::FixedBytes)
|
||||
annotation.isLValue = false;
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -1317,6 +1319,22 @@ bool TypeChecker::visit(IndexAccess const& _access)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Type::Category::FixedBytes:
|
||||
{
|
||||
FixedBytesType const& bytesType = dynamic_cast<FixedBytesType const&>(*baseType);
|
||||
if (!index)
|
||||
typeError(_access.location(), "Index expression cannot be omitted.");
|
||||
else
|
||||
{
|
||||
expectType(*index, IntegerType(256));
|
||||
if (auto integerType = dynamic_cast<IntegerConstantType const*>(type(*index).get()))
|
||||
if (bytesType.numBytes() <= integerType->literalValue(nullptr))
|
||||
typeError(_access.location(), "Out of bounds array access.");
|
||||
}
|
||||
resultType = make_shared<FixedBytesType>(1);
|
||||
isLValue = false; // @todo this heavily depends on how it is embedded
|
||||
break;
|
||||
}
|
||||
default:
|
||||
fatalTypeError(
|
||||
_access.baseExpression().location(),
|
||||
|
||||
Reference in new issue
Block a user