mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #10003 from ethereum/more-tests-and-docs-for-mixed-abi-encoder-use-checks
More tests and some minimal docs for mixed ABI encoder use
This commit is contained in:
commit
e7603d7590
@ -111,6 +111,14 @@ activate it using ``pragma experimental ABIEncoderV2;`` - we kept
|
|||||||
the same pragma, even though it is not considered experimental
|
the same pragma, even though it is not considered experimental
|
||||||
anymore.
|
anymore.
|
||||||
|
|
||||||
|
The set of types supported by the new encoder is a strict superset of
|
||||||
|
the ones supported by the old one. Contracts that use it can interact with ones
|
||||||
|
that do not without limitations. The reverse is possible only as long as the
|
||||||
|
non-``ABIEncoderV2`` contract does not try to make calls that would require
|
||||||
|
decoding types only supported by the new encoder. The compiler can detect this
|
||||||
|
and will issue an error. Simply enabling ``ABIEncoderV2`` for your contract is
|
||||||
|
enough to make the error go away.
|
||||||
|
|
||||||
.. _smt_checker:
|
.. _smt_checker:
|
||||||
|
|
||||||
SMTChecker
|
SMTChecker
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
struct Item {
|
||||||
|
uint x;
|
||||||
|
uint y;
|
||||||
|
}
|
||||||
|
|
||||||
|
contract D {
|
||||||
|
Item[][][] public items;
|
||||||
|
|
||||||
|
function test() public view returns (uint) {
|
||||||
|
// The autogenerated getters to not use ABI encoder.
|
||||||
|
(uint a, uint b) = this.items(1, 2, 3);
|
||||||
|
return a + b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
@ -0,0 +1,17 @@
|
|||||||
|
struct Item {
|
||||||
|
uint x;
|
||||||
|
uint y;
|
||||||
|
}
|
||||||
|
|
||||||
|
contract D {
|
||||||
|
Item[][][] public items;
|
||||||
|
|
||||||
|
function test() public view returns (uint) {
|
||||||
|
// The autogenerated getters to not use ABI encoder.
|
||||||
|
Item memory item = this.items(1, 2, 3);
|
||||||
|
return item.x + item.y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 7364: (202-240): Different number of components on the left hand side (1) than on the right hand side (2).
|
||||||
|
// TypeError 9574: (202-240): Type uint256 is not implicitly convertible to expected type struct Item memory.
|
@ -0,0 +1,22 @@
|
|||||||
|
==== Source: A ====
|
||||||
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
|
library L {
|
||||||
|
struct Item {
|
||||||
|
uint x;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f(uint) external view returns (Item memory) {}
|
||||||
|
}
|
||||||
|
==== Source: B ====
|
||||||
|
import "A";
|
||||||
|
|
||||||
|
contract D {
|
||||||
|
using L for uint;
|
||||||
|
|
||||||
|
function test() public {
|
||||||
|
uint(1).f();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 2428: (B:86-97): The type of return parameter 1, struct L.Item, is only supported in ABIEncoderV2. Use "pragma experimental ABIEncoderV2;" to enable the feature.
|
Loading…
Reference in New Issue
Block a user