Tests, Docs and Changelog

This commit is contained in:
Harikrishnan Mulackal
2020-06-30 16:53:41 +05:30
parent d41eaeba56
commit eeadb5a6b5
48 changed files with 215 additions and 124 deletions
@@ -0,0 +1,8 @@
pragma experimental ABIEncoderV2;
contract Test {
function f(mapping(uint => uint)[] memory x) public pure {}
}
// ----
// TypeError 4103: (66-98): Types containing (nested) mappings can only be parameters or return variables of internal or library functions.
// TypeError 4061: (66-98): Type mapping(uint256 => uint256)[] is only valid in storage because it contains a (nested) mapping.
@@ -0,0 +1,6 @@
pragma experimental ABIEncoderV2;
library L {
function f(mapping(uint => uint)[2] memory a) external pure returns (mapping(uint => uint)[2] memory) {}
}
// ----
// TypeError 4061: (61-94): Type mapping(uint256 => uint256)[2] is only valid in storage because it contains a (nested) mapping.
@@ -5,7 +5,6 @@ contract C {
struct S { uint256 [ ] [ 0.425781 ether ] s1 ;
uint [ 2 ** 0xFF ] [ 2 ** 0x42 ] s2 ;
X s3 ;
mapping ( uint => address payable ) c ;
uint [ 9 hours ** 16 ] d ;
string s ;
}
@@ -14,4 +13,4 @@ contract C {
}
}
// ----
// TypeError 1534: (530-540): Type too large for memory.
// TypeError 1534: (474-484): Type too large for memory.
@@ -11,3 +11,4 @@ contract Test {
}
// ----
// DeclarationError 2333: (157-198): Identifier already declared.
// TypeError 4061: (268-300): Type struct Test.RecursiveStruct[1] is only valid in storage because it contains a (nested) mapping.
@@ -4,4 +4,4 @@ library L {
}
}
// ----
// TypeError 9214: (108-109): Mappings cannot be assigned to.
// TypeError 9214: (108-109): Types in storage containing (nested) mappings cannot be assigned to.
@@ -9,4 +9,4 @@ contract Test {
}
}
// ----
// TypeError 4994: (208-218): Member "b1" is not available in struct Test.S1 memory outside of storage.
// TypeError 4061: (161-172): Type struct Test.S2 is only valid in storage because it contains a (nested) mapping.
@@ -3,8 +3,7 @@ contract Test {
S s;
function f() public {
S memory x;
x.b[1];
}
}
// ----
// TypeError 4994: (118-121): Member "b" is not available in struct Test.S memory outside of storage.
// TypeError 4061: (104-114): Type struct Test.S is only valid in storage because it contains a (nested) mapping.
@@ -9,3 +9,4 @@ contract test {
}
}
// ----
// TypeError 9214: (152-156): Types in storage containing (nested) mappings cannot be assigned to.
@@ -0,0 +1,9 @@
pragma experimental ABIEncoderV2;
contract C {
struct S { mapping(uint => uint) a; }
function f(S memory) public {}
}
// ----
// TypeError 4103: (105-113): Types containing (nested) mappings can only be parameters or return variables of internal or library functions.
// TypeError 4061: (105-113): Type struct C.S is only valid in storage because it contains a (nested) mapping.
@@ -5,4 +5,5 @@ contract C {
function f(S memory) public {}
}
// ----
// TypeError 4103: (105-113): Only libraries are allowed to use the mapping type in public or external functions.
// TypeError 4103: (105-113): Types containing (nested) mappings can only be parameters or return variables of internal or library functions.
// TypeError 4061: (105-113): Type struct C.S is only valid in storage because it contains a (nested) mapping.
@@ -0,0 +1,10 @@
pragma experimental ABIEncoderV2;
contract C {
struct T { mapping(uint => uint) a; }
struct S { T[][2] b; }
function f(S memory) public {}
}
// ----
// TypeError 4103: (132-140): Types containing (nested) mappings can only be parameters or return variables of internal or library functions.
// TypeError 4061: (132-140): Type struct C.S is only valid in storage because it contains a (nested) mapping.
@@ -6,4 +6,5 @@ contract C {
function f(S memory) public {}
}
// ----
// TypeError 4103: (132-140): Only libraries are allowed to use the mapping type in public or external functions.
// TypeError 4103: (132-140): Types containing (nested) mappings can only be parameters or return variables of internal or library functions.
// TypeError 4061: (132-140): Type struct C.S is only valid in storage because it contains a (nested) mapping.
@@ -4,4 +4,4 @@ contract C {
}
}
// ----
// TypeError 1164: (94-117): Type cannot live outside storage.
// TypeError 1164: (94-117): Array containing a (nested) mapping cannot be constructed in memory.
@@ -2,6 +2,6 @@ contract c {
event e(uint indexed a, mapping(uint => uint) indexed b, bool indexed c, uint indexed d, uint indexed e) anonymous;
}
// ----
// TypeError 3448: (41-72): Type is required to live outside storage.
// TypeError 3448: (41-72): Type containing a (nested) mapping is not allowed as event parameter type.
// TypeError 3417: (41-72): Internal or recursive type is not allowed as event parameter type.
// TypeError 8598: (17-132): More than 4 indexed arguments for anonymous event.
@@ -6,4 +6,4 @@ contract C {
}
}
// ----
// TypeError 9755: (117-126): Wrong argument count for struct constructor: 1 arguments given but expected 2. Members that have to be skipped in memory: c
// TypeError 9515: (117-126): Struct containing a (nested) mapping cannot be constructed.
@@ -0,0 +1,15 @@
pragma experimental ABIEncoderV2;
contract test {
struct S {
T t;
}
struct T {
mapping (uint => uint) k;
}
function f(S calldata b) external {
}
}
// ----
// TypeError 4103: (155-167): Types containing (nested) mappings can only be parameters or return variables of internal or library functions.
// TypeError 4061: (155-167): Type struct test.S is only valid in storage because it contains a (nested) mapping.
@@ -1,3 +1,5 @@
pragma experimental ABIEncoderV2;
contract Test {
struct MyStructName {
address addr;
@@ -7,4 +9,4 @@ contract Test {
function f(MyStructName memory s) public {}
}
// ----
// TypeError 4103: (112-133): Recursive type not allowed for public or external contract functions.
// TypeError 4103: (147-168): Recursive type not allowed for public or external contract functions.
@@ -1,7 +1,9 @@
pragma experimental ABIEncoderV2;
contract C {
struct S { uint a; S[] sub; }
function f() public pure returns (uint, S memory) {
}
}
// ----
// TypeError 4103: (91-99): Recursive type not allowed for public or external contract functions.
// TypeError 4103: (126-134): Recursive type not allowed for public or external contract functions.
@@ -1,7 +1,9 @@
pragma experimental ABIEncoderV2;
contract C {
struct S { uint a; S[2][] sub; }
function f() public pure returns (uint, S memory) {
}
}
// ----
// TypeError 4103: (94-102): Recursive type not allowed for public or external contract functions.
// TypeError 4103: (129-137): Recursive type not allowed for public or external contract functions.
@@ -1,3 +1,5 @@
pragma experimental ABIEncoderV2;
contract C {
struct S { uint a; S[][][] sub; }
struct T { S s; }
@@ -5,4 +7,4 @@ contract C {
}
}
// ----
// TypeError 4103: (119-129): Recursive type not allowed for public or external contract functions.
// TypeError 4103: (154-164): Recursive type not allowed for public or external contract functions.
@@ -7,4 +7,4 @@ contract D {
}
}
// ----
// TypeError 9214: (160-161): Mappings cannot be assigned to.
// TypeError 9214: (160-161): Types in storage containing (nested) mappings cannot be assigned to.
@@ -20,8 +20,18 @@ contract G {
uint x = 1;
mapping (uint => uint) b = x;
}
contract H {
struct S {mapping (uint => uint) a;}
S x;
S y = x;
S z = z;
}
// ----
// TypeError 6280: (17-67): Mappings cannot be assigned to.
// TypeError 6280: (120-148): Mappings cannot be assigned to.
// TypeError 9214: (263-264): Mappings cannot be assigned to.
// TypeError 6280: (312-340): Mappings cannot be assigned to.
// TypeError 6280: (17-67): Types in storage containing (nested) mappings cannot be assigned to.
// TypeError 6280: (120-148): Types in storage containing (nested) mappings cannot be assigned to.
// TypeError 9214: (263-264): Types in storage containing (nested) mappings cannot be assigned to.
// TypeError 6280: (312-340): Types in storage containing (nested) mappings cannot be assigned to.
// TypeError 6280: (407-414): Types in storage containing (nested) mappings cannot be assigned to.
// TypeError 6280: (417-424): Types in storage containing (nested) mappings cannot be assigned to.
@@ -8,7 +8,7 @@ contract test {
}
}
// ----
// TypeError 9214: (126-129): Mappings cannot be assigned to.
// TypeError 9214: (144-147): Mappings cannot be assigned to.
// TypeError 9214: (163-166): Mappings cannot be assigned to.
// TypeError 9214: (168-171): Mappings cannot be assigned to.
// TypeError 9214: (126-129): Types in storage containing (nested) mappings cannot be assigned to.
// TypeError 9214: (144-147): Types in storage containing (nested) mappings cannot be assigned to.
// TypeError 9214: (163-166): Types in storage containing (nested) mappings cannot be assigned to.
// TypeError 9214: (168-171): Types in storage containing (nested) mappings cannot be assigned to.
@@ -11,7 +11,7 @@ contract test {
}
}
// ----
// TypeError 9214: (172-180): Mappings cannot be assigned to.
// TypeError 9214: (195-203): Mappings cannot be assigned to.
// TypeError 9214: (219-227): Mappings cannot be assigned to.
// TypeError 9214: (229-237): Mappings cannot be assigned to.
// TypeError 9214: (172-180): Types in storage containing (nested) mappings cannot be assigned to.
// TypeError 9214: (195-203): Types in storage containing (nested) mappings cannot be assigned to.
// TypeError 9214: (219-227): Types in storage containing (nested) mappings cannot be assigned to.
// TypeError 9214: (229-237): Types in storage containing (nested) mappings cannot be assigned to.
@@ -0,0 +1,6 @@
contract test {
function f(mapping(uint => uint)[2] memory b) internal {
}
}
// ----
// TypeError 4061: (31-64): Type mapping(uint256 => uint256)[2] is only valid in storage because it contains a (nested) mapping.
@@ -0,0 +1,13 @@
library Set {
struct Data { mapping(uint => bool) flags; }
function insert(Data storage self, uint value)
public
returns (bool)
{
if (self.flags[value])
return false; // already there
self.flags[value] = true;
return true;
}
}
@@ -3,4 +3,3 @@ library L {
}
}
// ----
// TypeError 3312: (27-58): Type is required to live outside storage.
@@ -3,4 +3,3 @@ library L {
}
}
// ----
// TypeError 3312: (27-58): Type is required to live outside storage.
@@ -0,0 +1,7 @@
pragma experimental ABIEncoderV2;
library L {
struct S { mapping(uint => uint) m; }
function f(S memory a) external pure returns (S memory) {}
}
// ----
// TypeError 4061: (103-113): Type struct L.S is only valid in storage because it contains a (nested) mapping.
@@ -0,0 +1,6 @@
library Test {
struct Nested { mapping(uint => uint)[2][] a; uint y; }
struct X { Nested n; }
function f(X storage x) external {}
}
// ----
@@ -2,5 +2,5 @@ contract c {
function f1(mapping(uint => uint)[] calldata) pure external {}
}
// ----
// TypeError 3312: (29-61): Type is required to live outside storage.
// TypeError 4103: (29-61): Only libraries are allowed to use the mapping type in public or external functions.
// TypeError 4103: (29-61): Types containing (nested) mappings can only be parameters or return variables of internal or library functions.
// TypeError 4061: (29-61): Type mapping(uint256 => uint256)[] is only valid in storage because it contains a (nested) mapping.
@@ -2,5 +2,5 @@ contract c {
function f1(mapping(uint => uint) calldata) pure external returns (mapping(uint => uint) memory) {}
}
// ----
// TypeError 3442: (29-59): Mapping types can only have a data location of "storage" and thus only be parameters or return variables for internal or library functions.
// TypeError 3442: (84-112): Mapping types can only have a data location of "storage" and thus only be parameters or return variables for internal or library functions.
// TypeError 4103: (29-59): Types containing (nested) mappings can only be parameters or return variables of internal or library functions.
// TypeError 4061: (29-59): Type mapping(uint256 => uint256) is only valid in storage because it contains a (nested) mapping.
@@ -3,4 +3,4 @@ contract c {
function f5(mapping(uint => uint) memory) pure internal {}
}
// ----
// TypeError 5380: (93-121): Mapping types can only have a data location of "storage".
// TypeError 4061: (93-121): Type mapping(uint256 => uint256) is only valid in storage because it contains a (nested) mapping.
@@ -2,4 +2,5 @@ contract c {
function f3(mapping(uint => uint) memory) view public {}
}
// ----
// TypeError 3442: (29-57): Mapping types can only have a data location of "storage" and thus only be parameters or return variables for internal or library functions.
// TypeError 4103: (29-57): Types containing (nested) mappings can only be parameters or return variables of internal or library functions.
// TypeError 4061: (29-57): Type mapping(uint256 => uint256) is only valid in storage because it contains a (nested) mapping.
@@ -0,0 +1,12 @@
pragma experimental ABIEncoderV2;
contract test {
struct S {
mapping (uint => uint) s;
}
function f(S calldata b) external {
}
}
// ----
// TypeError 4103: (121-133): Types containing (nested) mappings can only be parameters or return variables of internal or library functions.
// TypeError 4061: (121-133): Type struct test.S is only valid in storage because it contains a (nested) mapping.
@@ -3,4 +3,5 @@ contract C {
}
}
// ----
// TypeError 3442: (51-79): Mapping types can only have a data location of "storage" and thus only be parameters or return variables for internal or library functions.
// TypeError 4103: (51-79): Types containing (nested) mappings can only be parameters or return variables of internal or library functions.
// TypeError 4061: (51-79): Type mapping(uint256 => uint256) is only valid in storage because it contains a (nested) mapping.
@@ -0,0 +1,8 @@
pragma experimental ABIEncoderV2;
contract C {
struct S { mapping(uint => uint) a; }
function f(S memory) public {}
}
// ----
// TypeError 4103: (104-112): Types containing (nested) mappings can only be parameters or return variables of internal or library functions.
// TypeError 4061: (104-112): Type struct C.S is only valid in storage because it contains a (nested) mapping.
@@ -0,0 +1,10 @@
pragma experimental ABIEncoderV2;
contract C {
struct S { mapping(uint => uint) a; }
struct T { S s; }
struct U { T t; }
function f(U memory) public {}
}
// ----
// TypeError 4103: (148-156): Types containing (nested) mappings can only be parameters or return variables of internal or library functions.
// TypeError 4061: (148-156): Type struct C.U is only valid in storage because it contains a (nested) mapping.
@@ -0,0 +1,20 @@
contract Test {
struct S {
T[] t;
}
struct T {
U[] u;
}
struct U {
S[] s;
mapping (uint => S) map;
}
function f() public {
S memory s;
}
}
// ----
// TypeError 4061: (143-153): Type struct Test.S is only valid in storage because it contains a (nested) mapping.
@@ -0,0 +1,15 @@
contract Test {
struct S {
uint8 a;
mapping(uint256 => uint256) b;
uint8 c;
}
S s;
function f() public returns (uint256) {
S memory x;
}
}
// ----
// TypeError 4061: (172-182): Type struct Test.S is only valid in storage because it contains a (nested) mapping.