Disallow internal function types as parameters for public/external library function

This commit is contained in:
Mathias Baumann
2019-03-21 07:25:57 +01:00
parent 0fbea8a1a0
commit 8e899a0d32
22 changed files with 188 additions and 86 deletions
@@ -0,0 +1,6 @@
library L {
// Used to cause internal error
function f(function(uint) internal returns (uint)[] memory x) public { }
}
// ----
// TypeError: (63-112): Internal type is not allowed for public or external functions.
@@ -0,0 +1,6 @@
library L {
// Used to cause internal error
function g(function(uint) internal returns (uint)[] storage x) public { }
}
// ----
// TypeError: (63-113): Internal type is not allowed for public or external functions.
@@ -5,4 +5,4 @@ contract C {
}
}
// ----
// TypeError: (124-164): Internal or recursive type is not allowed for public or external functions.
// TypeError: (124-164): Internal type is not allowed for public or external functions.
@@ -3,4 +3,4 @@ library L {
}
}
// ----
// TypeError: (27-67): Internal or recursive type is not allowed for public or external functions.
// TypeError: (27-67): Internal type is not allowed for public or external functions.
@@ -4,4 +4,4 @@ contract C {
}
}
// ----
// TypeError: (129-169): Internal or recursive type is not allowed for public or external functions.
// TypeError: (129-169): Internal type is not allowed for public or external functions.
@@ -0,0 +1,9 @@
library L {
struct S
{
function(uint) internal returns (uint)[] x;
}
function f(S storage s) public { }
}
// ----
// TypeError: (104-115): Internal type is not allowed for public or external functions.
@@ -6,4 +6,4 @@ contract C {
}
// ----
// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
// TypeError: (103-111): Internal or recursive type is not allowed for public or external functions.
// TypeError: (103-111): Internal type is not allowed for public or external functions.
@@ -6,4 +6,4 @@ contract C {
}
// ----
// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
// TypeError: (105-113): Internal or recursive type is not allowed for public or external functions.
// TypeError: (105-113): Only libraries are allowed to use the mapping type in public or external functions.
@@ -7,4 +7,4 @@ contract C {
}
// ----
// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
// TypeError: (132-140): Internal or recursive type is not allowed for public or external functions.
// TypeError: (132-140): Only libraries are allowed to use the mapping type in public or external functions.
@@ -0,0 +1,10 @@
contract Test {
struct MyStructName {
address addr;
MyStructName[] x;
}
function f(MyStructName memory s) public {}
}
// ----
// TypeError: (112-133): Recursive type not allowed for public or external contract functions.
@@ -0,0 +1,9 @@
library Test {
struct MyStructName {
address addr;
MyStructName[] x;
}
function f(MyStructName storage s) public {}
}
// ----
@@ -0,0 +1,14 @@
pragma experimental ABIEncoderV2;
library Test {
struct MyStructName {
address addr;
MyStructName[] x;
}
function f(MyStructName memory _x) public {
}
}
// ----
// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
// TypeError: (146-168): Recursive structs can only be passed as storage pointers to libraries, not as memory objects to contract functions.
@@ -8,4 +8,4 @@ contract Data {
}
// ----
// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
// TypeError: (63-78): Internal or recursive type is not allowed for public or external functions.
// TypeError: (63-78): Recursive type not allowed for public or external contract functions.
@@ -0,0 +1,11 @@
library Test {
struct MyStructName {
address addr;
MyStructName[] x;
function() internal y;
}
function f(MyStructName storage s) public {}
}
// ----
// TypeError: (142-164): Internal type is not allowed for public or external functions.
@@ -4,4 +4,4 @@ contract C {
}
}
// ----
// TypeError: (91-99): Internal or recursive type is not allowed for public or external functions.
// TypeError: (91-99): Recursive type not allowed for public or external contract functions.
@@ -4,4 +4,4 @@ contract C {
}
}
// ----
// TypeError: (94-102): Internal or recursive type is not allowed for public or external functions.
// TypeError: (94-102): Recursive type not allowed for public or external contract functions.
@@ -5,4 +5,4 @@ contract C {
}
}
// ----
// TypeError: (119-129): Internal or recursive type is not allowed for public or external functions.
// TypeError: (119-129): Recursive type not allowed for public or external contract functions.
@@ -3,4 +3,4 @@ contract c {
}
// ----
// TypeError: (29-61): Type is required to live outside storage.
// TypeError: (29-61): Internal or recursive type is not allowed for public or external functions.
// TypeError: (29-61): Only libraries are allowed to use the mapping type in public or external functions.