Allow mapping arguments and return values in internal library functions.

This commit is contained in:
Daniel Kirchner
2018-08-13 14:31:10 +02:00
parent a2c754b3fe
commit 57ada1d69e
15 changed files with 245 additions and 1 deletions
@@ -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,7 @@
// This is expected to fail now, but may work in the future.
contract C {
function f(mapping(uint => uint) storage) internal pure {
}
}
// ----
// TypeError: (89-110): Type is required to live outside storage.
@@ -0,0 +1,7 @@
// This is expected to fail now, but may work in the future.
contract C {
function f(mapping(uint => uint) storage) private pure {
}
}
// ----
// TypeError: (89-110): Type is required to live outside storage.
@@ -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 @@
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,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.