Merge pull request #6080 from ethereum/library-index-access

Disallow index access on contracts and libraries
This commit is contained in:
chriseth
2019-02-26 13:26:05 +01:00
committed by GitHub
5 changed files with 28 additions and 0 deletions
+2
View File
@@ -2208,6 +2208,8 @@ bool TypeChecker::visit(IndexAccess const& _access)
case Type::Category::TypeType:
{
TypeType const& typeType = dynamic_cast<TypeType const&>(*baseType);
if (dynamic_cast<ContractType const*>(typeType.actualType().get()))
m_errorReporter.typeError(_access.location(), "Index access for contracts or libraries is not possible.");
if (!index)
resultType = make_shared<TypeType>(make_shared<ArrayType>(DataLocation::Memory, typeType.actualType()));
else