Additional tests for ABIEncoderV1 calls using ABIEncoderV2 types

This commit is contained in:
Kamil Śliwak 2020-10-09 15:42:28 +02:00
parent e5fe524786
commit 94a49fcc4a
3 changed files with 54 additions and 0 deletions

View File

@ -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;
}
}
// ----

View File

@ -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.

View File

@ -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.