mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add abi.decode(bytes data, (...))
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
// This restriction might be lifted in the future
|
||||
contract C {
|
||||
function f() public pure {
|
||||
abi.decode("abc", (bytes calldata));
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// ParserError: (121-129): Expected ',' but got 'calldata'
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
abi.decode();
|
||||
abi.decode(msg.data);
|
||||
abi.decode(msg.data, uint, uint);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (46-58): This function takes two arguments, but 0 were provided.
|
||||
// TypeError: (64-84): This function takes two arguments, but 1 were provided.
|
||||
// TypeError: (90-122): This function takes two arguments, but 3 were provided.
|
||||
// TypeError: (111-115): The second argument to "abi.decode" has to be a tuple of types.
|
||||
@@ -0,0 +1,7 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
abi.decode("abc", (bytes memory, uint[][2] memory));
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// ParserError: (71-77): Expected ',' but got 'memory'
|
||||
@@ -0,0 +1,10 @@
|
||||
pragma experimental "ABIEncoderV2";
|
||||
|
||||
contract C {
|
||||
struct S { uint x; uint[] b; }
|
||||
function f() public pure returns (S memory, bytes memory, uint[][2] memory) {
|
||||
return abi.decode("abc", (S, bytes, uint[][2]));
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (0-35): Experimental features are turned on. Do not use experimental features on live deployments.
|
||||
@@ -0,0 +1,11 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
abi.decode("abc", uint);
|
||||
abi.decode("abc", this);
|
||||
abi.decode("abc", f());
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (64-68): The second argument to "abi.decode" has to be a tuple of types.
|
||||
// TypeError: (93-97): The second argument to "abi.decode" has to be a tuple of types.
|
||||
// TypeError: (122-125): The second argument to "abi.decode" has to be a tuple of types.
|
||||
@@ -0,0 +1,5 @@
|
||||
contract C {
|
||||
function f() public pure returns (uint, bytes32, C) {
|
||||
return abi.decode("abc", (uint, bytes32, C));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
contract C {
|
||||
function f() public pure returns (uint) {
|
||||
return abi.decode("abc", (uint));
|
||||
}
|
||||
}
|
||||
// ----
|
||||
@@ -0,0 +1,8 @@
|
||||
// This restriction might be lifted in the future
|
||||
contract C {
|
||||
function f() {
|
||||
abi.decode("abc", (bytes storage));
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// ParserError: (109-116): Expected ',' but got 'storage'
|
||||
Reference in New Issue
Block a user