Allow struct encoding with new encoder.

This commit is contained in:
chriseth
2018-04-12 16:37:16 +02:00
parent 7343c40283
commit 75b8828666
6 changed files with 179 additions and 12 deletions
@@ -0,0 +1,17 @@
contract C {
struct S { uint x; }
S s;
struct T { uint y; }
T t;
function f() public view {
abi.encode(s, t);
}
function g() public view {
abi.encodePacked(s, t);
}
}
// ----
// TypeError: (131-132): This type cannot be encoded.
// TypeError: (134-135): This type cannot be encoded.
// TypeError: (200-201): This type cannot be encoded.
// TypeError: (203-204): This type cannot be encoded.
@@ -0,0 +1,18 @@
pragma experimental ABIEncoderV2;
contract C {
struct S { uint x; }
S s;
struct T { uint y; }
T t;
function f() public view {
abi.encode(s, t);
}
function g() public view {
abi.encodePacked(s, t);
}
}
// ----
// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
// TypeError: (235-236): This type cannot be encoded.
// TypeError: (238-239): This type cannot be encoded.
@@ -1,14 +1,13 @@
contract C {
struct S { uint x; }
S s;
struct T { }
struct T { uint y; }
T t;
function f() public pure {
function f() public view {
bytes32 a = sha256(s, t);
a;
}
}
// ----
// Warning: (51-63): Defining empty structs is deprecated.
// TypeError: (131-132): This type cannot be encoded.
// TypeError: (134-135): This type cannot be encoded.
// TypeError: (139-140): This type cannot be encoded.
// TypeError: (142-143): This type cannot be encoded.
@@ -0,0 +1,16 @@
pragma experimental ABIEncoderV2;
contract C {
struct S { uint x; }
S s;
struct T { uint y; }
T t;
function f() public view {
bytes32 a = sha256(s, t);
a;
}
}
// ----
// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
// TypeError: (174-175): This type cannot be encoded.
// TypeError: (177-178): This type cannot be encoded.