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,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.