Allow mappings of arrays as arguments and return values of internal functions.

This commit is contained in:
Daniel Kirchner
2018-08-13 16:33:37 +02:00
parent 4ae59acc09
commit 341128962f
13 changed files with 101 additions and 4 deletions
@@ -0,0 +1,6 @@
contract C {
function f(mapping(uint => uint)[] storage) external pure {
}
}
// ----
// TypeError: (28-51): Location has to be calldata for external functions (remove the "memory" or "storage" keyword).
@@ -0,0 +1,5 @@
contract C {
function f(mapping(uint => uint)[] storage) internal pure {
}
}
// ----
@@ -0,0 +1,5 @@
contract C {
function f(mapping(uint => uint)[] storage) private pure {
}
}
// ----
@@ -0,0 +1,6 @@
contract C {
function f(mapping(uint => uint)[] storage) public pure {
}
}
// ----
// TypeError: (28-51): Location has to be memory for publicly visible functions (remove the "storage" or "calldata" keyword).
@@ -0,0 +1,6 @@
library L {
function f(mapping(uint => uint)[] storage) external pure {
}
}
// ----
// TypeError: (27-50): Type is required to live outside storage.
@@ -0,0 +1,4 @@
library L {
function f(mapping(uint => uint)[] storage) internal pure {
}
}
@@ -0,0 +1,4 @@
library L {
function f(mapping(uint => uint)[] storage) private pure {
}
}
@@ -0,0 +1,6 @@
library L {
function f(mapping(uint => uint)[] storage) public pure {
}
}
// ----
// TypeError: (27-50): Type is required to live outside storage.
@@ -0,0 +1,6 @@
contract C {
function f() external pure returns (mapping(uint=>uint)[] storage m) {
}
}
// ----
// TypeError: (53-84): Location has to be memory for publicly visible functions (remove the "storage" or "calldata" keyword).
@@ -0,0 +1,16 @@
contract C {
mapping(uint=>uint)[] m;
function f() internal view returns (mapping(uint=>uint)[] storage) {
return m;
}
function g() private view returns (mapping(uint=>uint)[] storage) {
return m;
}
function h() internal view returns (mapping(uint=>uint)[] storage r) {
r = m;
}
function i() private view returns (mapping(uint=>uint)[] storage r) {
(r,r) = (m,m);
}
}
// ----
@@ -0,0 +1,6 @@
contract C {
function f() public pure returns (mapping(uint=>uint)[] storage m) {
}
}
// ----
// TypeError: (51-82): Location has to be memory for publicly visible functions (remove the "storage" or "calldata" keyword).