mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Allow struct encoding with new encoder.
This commit is contained in:
@@ -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.
|
||||
+4
-5
@@ -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.
|
||||
|
||||
+16
@@ -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.
|
||||
Reference in New Issue
Block a user