Fix ICE by avoiding copyForLocation() on ArraySliceType

This commit is contained in:
Mathias Baumann 2020-05-26 17:23:49 +02:00
parent 5fedb4eab0
commit b3cafe4583
4 changed files with 16 additions and 4 deletions

View File

@ -13,6 +13,7 @@ Compiler Features:
Bugfixes:
* Optimizer: Fixed a bug in BlockDeDuplicator.
* Type Checker: Disallow assignments to storage variables of type ``mapping``.
* Type Checker: Fix internal compiler error when accessing members of array slices.
* NatSpec: DocString block is terminated when encountering an empty line.
* Scanner: Fix bug when two empty NatSpec comments lead to scanning past EOL.
* Code Generator: Trigger proper unimplemented errors on certain array copy operations.

View File

@ -2555,7 +2555,7 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess)
if (possibleMembers.empty())
{
if (initialMemberCount == 0)
if (initialMemberCount == 0 && !dynamic_cast<ArraySliceType const*>(exprType))
{
// Try to see if the member was removed because it is only available for storage types.
auto storageType = TypeProvider::withLocationIfReference(

View File

@ -349,14 +349,17 @@ TypePointer Type::fullEncodingType(bool _inLibraryCall, bool _encoderV2, bool) c
MemberList::MemberMap Type::boundFunctions(Type const& _type, ContractDefinition const& _scope)
{
// Normalise data location of type.
TypePointer type = TypeProvider::withLocationIfReference(DataLocation::Storage, &_type);
DataLocation typeLocation = DataLocation::Storage;
if (auto refType = dynamic_cast<ReferenceType const*>(&_type))
typeLocation = refType->location();
set<Declaration const*> seenFunctions;
MemberList::MemberMap members;
for (ContractDefinition const* contract: _scope.annotation().linearizedBaseContracts)
for (UsingForDirective const* ufd: contract->usingForDirectives())
{
if (ufd->typeName() && *type != *TypeProvider::withLocationIfReference(
DataLocation::Storage,
if (ufd->typeName() && _type != *TypeProvider::withLocationIfReference(
typeLocation,
ufd->typeName()->annotation().type
))
continue;

View File

@ -0,0 +1,8 @@
// Used to cause ICE
contract C {
function f(uint[] calldata x) external pure {
x[1:2].a;
}
}
// ----
// TypeError: (92-100): Member "a" not found or not visible after argument-dependent lookup in uint256[] calldata slice.