mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #4798 from ethereum/mappingArgumentsAndReturns
Mapping arguments and returns
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
contract C {
|
||||
function f() internal pure returns (mapping(uint=>uint) storage r) { }
|
||||
}
|
||||
// ----
|
||||
// TypeError: (53-82): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
|
||||
@@ -0,0 +1,5 @@
|
||||
contract C {
|
||||
mapping(uint=>uint) m;
|
||||
function f() internal view returns (mapping(uint=>uint) storage r) { r = m; }
|
||||
}
|
||||
// ----
|
||||
@@ -0,0 +1,5 @@
|
||||
contract C {
|
||||
function f() internal pure returns (mapping(uint=>uint) storage) {}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (53-72): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
|
||||
@@ -0,0 +1,5 @@
|
||||
contract C {
|
||||
mapping(uint=>uint) m;
|
||||
function f() internal view returns (mapping(uint=>uint) storage) { return m; }
|
||||
}
|
||||
// ----
|
||||
@@ -0,0 +1,7 @@
|
||||
contract C {
|
||||
function f(mapping(uint => uint) storage) external pure {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (28-49): Type is required to live outside storage.
|
||||
// TypeError: (28-49): Internal or recursive type is not allowed for public or external functions.
|
||||
@@ -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,7 @@
|
||||
contract C {
|
||||
function f(mapping(uint => uint) storage) public pure {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (28-49): Type is required to live outside storage.
|
||||
// TypeError: (28-49): Internal or recursive type is not allowed for public or external functions.
|
||||
@@ -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 @@
|
||||
contract C {
|
||||
function f(function(mapping(uint=>uint) storage) external) public pure {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (37-56): Internal type cannot be used for external function type.
|
||||
@@ -0,0 +1,4 @@
|
||||
contract C {
|
||||
function f(function(mapping(uint=>uint) storage) internal) internal pure {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
contract C {
|
||||
function f(function() external returns (mapping(uint=>uint) storage)) public pure {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (57-76): Internal type cannot be used for external function type.
|
||||
@@ -0,0 +1,4 @@
|
||||
contract C {
|
||||
function f(function() internal returns (mapping(uint=>uint) storage)) internal pure {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
library L {
|
||||
function f(mapping(uint => uint) storage) external pure {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (27-48): 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-48): Type is required to live outside storage.
|
||||
@@ -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,10 @@
|
||||
library L
|
||||
{
|
||||
function f(mapping(uint => uint) storage a, mapping(uint => uint) storage b, bool c) external pure returns(mapping(uint => uint) storage) {
|
||||
return c ? a : b;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (27-58): Type is required to live outside storage.
|
||||
// TypeError: (60-91): Type is required to live outside storage.
|
||||
// TypeError: (123-144): Type is required to live outside storage.
|
||||
@@ -0,0 +1,6 @@
|
||||
library L
|
||||
{
|
||||
function f(mapping(uint => uint) storage a, mapping(uint => uint) storage b, bool c) internal pure returns(mapping(uint => uint) storage) {
|
||||
return c ? a : b;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
library L
|
||||
{
|
||||
function f(mapping(uint => uint) storage a, mapping(uint => uint) storage b, bool c) private pure returns(mapping(uint => uint) storage) {
|
||||
return c ? a : b;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
library L
|
||||
{
|
||||
function f(mapping(uint => uint) storage a, mapping(uint => uint) storage b, bool c) public pure returns(mapping(uint => uint) storage) {
|
||||
return c ? a : b;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (27-58): Type is required to live outside storage.
|
||||
// TypeError: (60-91): Type is required to live outside storage.
|
||||
// TypeError: (121-142): 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).
|
||||
@@ -1,4 +1,3 @@
|
||||
// This should be allowed in a future release.
|
||||
contract C {
|
||||
mapping(uint=>uint) m;
|
||||
function f() internal view returns (mapping(uint=>uint) storage) {
|
||||
@@ -15,7 +14,3 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (127-146): Type is required to live outside storage.
|
||||
// TypeError: (221-240): Type is required to live outside storage.
|
||||
// TypeError: (316-345): Type is required to live outside storage.
|
||||
// TypeError: (409-438): Type is required to live outside storage.
|
||||
|
||||
Reference in New Issue
Block a user