mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Disallows index access on contracts and libraries.
This commit is contained in:
parent
97d3b88f65
commit
2d0daae796
@ -19,6 +19,7 @@ Bugfixes:
|
|||||||
* Inline Assembly: Proper error message for missing variables.
|
* Inline Assembly: Proper error message for missing variables.
|
||||||
* Optimizer: Fix internal error related to unused tag removal across assemblies. This never generated any invalid code.
|
* Optimizer: Fix internal error related to unused tag removal across assemblies. This never generated any invalid code.
|
||||||
* SMTChecker: Fixed crash when used with fixed-sized arrays.
|
* SMTChecker: Fixed crash when used with fixed-sized arrays.
|
||||||
|
* TypeChecker: Fix internal error and disallow index access on contracts and libraries.
|
||||||
* Yul: Properly detect name clashes with functions before their declaration.
|
* Yul: Properly detect name clashes with functions before their declaration.
|
||||||
* Yul: Take builtin functions into account in the compilability checker.
|
* Yul: Take builtin functions into account in the compilability checker.
|
||||||
|
|
||||||
|
@ -2208,6 +2208,8 @@ bool TypeChecker::visit(IndexAccess const& _access)
|
|||||||
case Type::Category::TypeType:
|
case Type::Category::TypeType:
|
||||||
{
|
{
|
||||||
TypeType const& typeType = dynamic_cast<TypeType const&>(*baseType);
|
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)
|
if (!index)
|
||||||
resultType = make_shared<TypeType>(make_shared<ArrayType>(DataLocation::Memory, typeType.actualType()));
|
resultType = make_shared<TypeType>(make_shared<ArrayType>(DataLocation::Memory, typeType.actualType()));
|
||||||
else
|
else
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
contract C {
|
||||||
|
function f() view public {
|
||||||
|
C[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError: (52-56): Index access for contracts or libraries is not possible.
|
@ -0,0 +1,7 @@
|
|||||||
|
library C {
|
||||||
|
function f() view public {
|
||||||
|
C[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError: (51-55): Index access for contracts or libraries is not possible.
|
Loading…
Reference in New Issue
Block a user