Merge pull request #9958 from a3d4/fix-ice-storage-parameters-in-libraries

Fix ICE caused by storage parameters with nested mappings in libraries
This commit is contained in:
chriseth 2020-10-08 17:17:09 +02:00 committed by GitHub
commit b5a08f8641
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 2 deletions

View File

@ -1,5 +1,14 @@
### 0.7.4 (unreleased)
Important Bugfixes:
Compiler Features:
Bugfixes:
* Type Checker: Fix internal compiler error caused by storage parameters with nested mappings in libraries.
### 0.7.3 (2020-10-07)

View File

@ -599,8 +599,13 @@ bool TypeChecker::visit(VariableDeclaration const& _variable)
if (auto referenceType = dynamic_cast<ReferenceType const*>(varType))
{
auto result = referenceType->validForLocation(referenceType->location());
if (result && (_variable.isConstructorParameter() || _variable.isPublicCallableParameter()))
result = referenceType->validForLocation(DataLocation::CallData);
if (result)
{
bool isLibraryStorageParameter = (_variable.isLibraryFunctionParameter() && referenceType->location() == DataLocation::Storage);
bool callDataCheckRequired = ((_variable.isConstructorParameter() || _variable.isPublicCallableParameter()) && !isLibraryStorageParameter);
if (callDataCheckRequired)
result = referenceType->validForLocation(DataLocation::CallData);
}
if (!result)
{
solAssert(!result.message().empty(), "Expected detailed error message");

View File

@ -0,0 +1,6 @@
struct S { mapping(uint => uint)[2] a; }
contract C {
function f(S storage s) public {}
}
// ----
// TypeError 6651: (69-80): Data location must be "memory" or "calldata" for parameter in function, but "storage" was given.

View File

@ -0,0 +1,4 @@
struct S { mapping(uint => uint)[2] a; }
library L {
function f(S storage s) public {}
}

View File

@ -0,0 +1,5 @@
library Test {
struct Nested { mapping(uint => uint)[2][] a; }
struct X { Nested n; }
function f(X storage x) public {}
}