mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #10010 from ethereum/develop
Merge develop into breaking.
This commit is contained in:
+32
@@ -0,0 +1,32 @@
|
||||
==== Source: A ====
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
struct Data {
|
||||
uint a;
|
||||
uint[2] b;
|
||||
uint c;
|
||||
}
|
||||
|
||||
contract A {
|
||||
function get() public view returns (Data memory) {
|
||||
return Data(5, [uint(66), 77], 8);
|
||||
}
|
||||
}
|
||||
|
||||
contract B {
|
||||
function foo(A _a) public returns (uint) {
|
||||
return _a.get().b[1];
|
||||
}
|
||||
}
|
||||
==== Source: B ====
|
||||
import "A";
|
||||
|
||||
contract C is B {
|
||||
function test() public returns (uint) {
|
||||
return foo(new A());
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// test() -> 77
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
==== Source: A ====
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
struct Data {
|
||||
uint value;
|
||||
}
|
||||
|
||||
contract A {
|
||||
function get() public view returns (Data memory) {
|
||||
return Data(5);
|
||||
}
|
||||
}
|
||||
|
||||
contract B {
|
||||
uint x = 10;
|
||||
uint y = 10;
|
||||
|
||||
modifier updateStorage() {
|
||||
A a = new A();
|
||||
x = a.get().value;
|
||||
_;
|
||||
y = a.get().value;
|
||||
}
|
||||
}
|
||||
==== Source: B ====
|
||||
import "A";
|
||||
|
||||
contract C is B {
|
||||
function test()
|
||||
public
|
||||
updateStorage
|
||||
returns (uint, uint)
|
||||
{
|
||||
return (x, y);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// test() -> 5, 10
|
||||
@@ -14,5 +14,7 @@ contract C {
|
||||
two = data.x;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(uint256): 7 -> 7, 8
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
contract Base {
|
||||
function f(uint n) public returns (uint) {
|
||||
return 2 * n;
|
||||
}
|
||||
}
|
||||
|
||||
contract Child is Base {
|
||||
function g(uint n) public returns (uint) {
|
||||
return f(n);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// g(uint256): 4 -> 8
|
||||
@@ -0,0 +1,29 @@
|
||||
contract BaseBase {
|
||||
function f(uint n) public virtual returns (uint) {
|
||||
return 2 * n;
|
||||
}
|
||||
function s(uint n) public returns (uint) {
|
||||
return 4 * n;
|
||||
}
|
||||
}
|
||||
|
||||
contract Base is BaseBase {
|
||||
function f(uint n) public virtual override returns (uint) {
|
||||
return 3 * n;
|
||||
}
|
||||
}
|
||||
|
||||
contract Child is Base {
|
||||
function g(uint n) public returns (uint) {
|
||||
return f(n);
|
||||
}
|
||||
|
||||
function h(uint n) public returns (uint) {
|
||||
return s(n);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// g(uint256): 4 -> 12
|
||||
// h(uint256): 4 -> 16
|
||||
@@ -0,0 +1,32 @@
|
||||
contract BaseBase {
|
||||
function f(uint n) public virtual returns (uint) {
|
||||
return 2 * n;
|
||||
}
|
||||
|
||||
function s(uint n) public returns (uint) {
|
||||
return 4 * n;
|
||||
}
|
||||
}
|
||||
|
||||
contract Base is BaseBase {
|
||||
function f(uint n) public virtual override returns (uint) {
|
||||
return 3 * n;
|
||||
}
|
||||
}
|
||||
|
||||
contract Child is Base {
|
||||
function g(uint n) public returns (uint) {
|
||||
// calling base-bse function of a virtual overridden function.
|
||||
return BaseBase.f(n);
|
||||
}
|
||||
|
||||
function k(uint n) public returns (uint) {
|
||||
// Calling base-base function of a non-virtual function.
|
||||
return BaseBase.s(n);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// g(uint256): 4 -> 8
|
||||
// k(uint256): 4 -> 16
|
||||
@@ -0,0 +1,15 @@
|
||||
contract Base {
|
||||
function f(uint n) public returns (uint) {
|
||||
return 2 * n;
|
||||
}
|
||||
}
|
||||
|
||||
contract Child is Base {
|
||||
function g(uint n) public returns (uint) {
|
||||
return Base.f(n);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// g(uint256): 4 -> 8
|
||||
@@ -0,0 +1,20 @@
|
||||
pragma experimental SMTChecker;
|
||||
|
||||
contract C {
|
||||
uint t;
|
||||
constructor() {
|
||||
t = address(this).balance;
|
||||
}
|
||||
function f(address payable a, uint x) public {
|
||||
require(address(this).balance >= x);
|
||||
a.transfer(x);
|
||||
}
|
||||
function inv() public view {
|
||||
// If only looking at `f`, it looks like this.balance always decreases.
|
||||
// However, the edge case of a contract `selfdestruct` sending its remaining balance
|
||||
// to this contract should make the claim false (since there's no fallback/receive here).
|
||||
assert(address(this).balance == t);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 6328: (496-530): CHC: Assertion violation happens here.
|
||||
@@ -0,0 +1,12 @@
|
||||
pragma experimental SMTChecker;
|
||||
|
||||
contract C {
|
||||
address t;
|
||||
constructor() {
|
||||
t = address(this);
|
||||
}
|
||||
function inv() public view {
|
||||
assert(address(this) == t);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
pragma experimental SMTChecker;
|
||||
|
||||
abstract contract D {
|
||||
function d() external virtual;
|
||||
}
|
||||
|
||||
contract C {
|
||||
address t;
|
||||
constructor() {
|
||||
t = address(this);
|
||||
}
|
||||
function f(D d) public {
|
||||
address a = address(this);
|
||||
d.d();
|
||||
assert(address(this) == t);
|
||||
assert(a == t);
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
pragma experimental SMTChecker;
|
||||
|
||||
contract C {
|
||||
address t;
|
||||
constructor() {
|
||||
t = address(this);
|
||||
}
|
||||
function f() public view {
|
||||
g(address(this));
|
||||
}
|
||||
function g(address a) internal view {
|
||||
assert(a == t);
|
||||
assert(a == address(this));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
pragma experimental SMTChecker;
|
||||
|
||||
contract C {
|
||||
function f(address payable a) public {
|
||||
require(address(this).balance > 1000);
|
||||
a.transfer(666);
|
||||
assert(address(this).balance > 100);
|
||||
// Fails.
|
||||
assert(address(this).balance > 500);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 6328: (199-234): CHC: Assertion violation happens here.
|
||||
@@ -17,4 +17,3 @@ contract C
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 4661: (297-321): BMC: Assertion violation happens here.
|
||||
|
||||
@@ -15,3 +15,4 @@ contract C
|
||||
}
|
||||
// ----
|
||||
// Warning 2661: (176-181): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
|
||||
// Warning 4661: (296-309): BMC: Assertion violation happens here.
|
||||
|
||||
@@ -11,6 +11,7 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 2519: (128-159): This declaration shadows an existing declaration.
|
||||
// Warning 6328: (207-227): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (231-245): CHC: Assertion violation happens here.
|
||||
// Warning 5729: (214-218): Assertion checker does not yet implement this type of function call.
|
||||
|
||||
-3
@@ -23,8 +23,6 @@ contract C {
|
||||
assert(s1[2].a[2] == s2.a[2]);
|
||||
s1[0].ts[3].y = 5;
|
||||
assert(s1[0].ts[3].y == s2.ts[3].y);
|
||||
s1[1].ts[4].a[5] = 6;
|
||||
assert(s1[1].ts[4].a[5] == s2.ts[4].a[5]);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
@@ -32,4 +30,3 @@ contract C {
|
||||
// Warning 6328: (327-354): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (376-405): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (430-465): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (493-534): CHC: Assertion violation happens here.
|
||||
|
||||
+15
@@ -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;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
+17
@@ -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.
|
||||
+22
@@ -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.
|
||||
@@ -0,0 +1,27 @@
|
||||
==== Source: A ====
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
struct Data {
|
||||
bool flag;
|
||||
}
|
||||
|
||||
contract A {
|
||||
function get() public view returns (Data memory) {}
|
||||
}
|
||||
|
||||
contract B {
|
||||
modifier validate() {
|
||||
A(0x00).get();
|
||||
_;
|
||||
}
|
||||
}
|
||||
==== Source: B ====
|
||||
import "A";
|
||||
|
||||
contract C is B {
|
||||
function foo()
|
||||
public
|
||||
validate()
|
||||
{}
|
||||
}
|
||||
// ----
|
||||
@@ -0,0 +1,33 @@
|
||||
==== Source: A ====
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
struct Data {
|
||||
bool flag;
|
||||
}
|
||||
|
||||
contract A {
|
||||
function get() public view returns (Data memory) {}
|
||||
}
|
||||
|
||||
contract B {
|
||||
constructor() validate {
|
||||
A(0x00).get();
|
||||
}
|
||||
|
||||
modifier validate() {
|
||||
A(0x00).get();
|
||||
_;
|
||||
}
|
||||
}
|
||||
|
||||
==== Source: B ====
|
||||
import "A";
|
||||
|
||||
contract C is B {}
|
||||
==== Source: C ====
|
||||
import "B";
|
||||
|
||||
contract D is C {
|
||||
constructor() validate B() validate C() validate {}
|
||||
}
|
||||
// ----
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
==== Source: A ====
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
struct Data {
|
||||
bool flag;
|
||||
}
|
||||
|
||||
contract A {
|
||||
function get() public view returns (Data memory) {}
|
||||
}
|
||||
|
||||
contract B {
|
||||
constructor() {
|
||||
A(0x00).get();
|
||||
}
|
||||
|
||||
function foo() public view {
|
||||
A(0x00).get();
|
||||
}
|
||||
}
|
||||
==== Source: B ====
|
||||
import "A";
|
||||
|
||||
contract C is B {}
|
||||
// ----
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
==== Source: A ====
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
struct Item {
|
||||
uint x;
|
||||
}
|
||||
|
||||
library L {
|
||||
event Ev(Item);
|
||||
}
|
||||
|
||||
contract C {
|
||||
function foo() public {
|
||||
emit L.Ev(Item(1));
|
||||
}
|
||||
}
|
||||
==== Source: B ====
|
||||
import "A";
|
||||
|
||||
contract D is C {}
|
||||
// ----
|
||||
@@ -0,0 +1,29 @@
|
||||
==== Source: A ====
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
struct Data {
|
||||
bool flag;
|
||||
}
|
||||
|
||||
contract A {
|
||||
function get() public view returns (Data memory) {}
|
||||
}
|
||||
|
||||
contract B {
|
||||
modifier validate() virtual {
|
||||
A(0x00).get();
|
||||
_;
|
||||
}
|
||||
}
|
||||
|
||||
==== Source: B ====
|
||||
import "A";
|
||||
|
||||
contract C is B {
|
||||
function foo() public pure validate {}
|
||||
|
||||
modifier validate() override {
|
||||
_;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
@@ -0,0 +1,52 @@
|
||||
==== Source: C ====
|
||||
import "X";
|
||||
import "V1A";
|
||||
import "V2A";
|
||||
import "V1B";
|
||||
|
||||
contract C is V1A, V2A, V1B {
|
||||
function foo()
|
||||
public
|
||||
modV1A
|
||||
modV2A // There should be no error for modV2A (it uses ABIEncoderV2)
|
||||
modV1B
|
||||
{
|
||||
}
|
||||
}
|
||||
==== Source: V1A ====
|
||||
import "X";
|
||||
|
||||
contract V1A {
|
||||
modifier modV1A() {
|
||||
_;
|
||||
}
|
||||
}
|
||||
==== Source: V1B ====
|
||||
import "X";
|
||||
|
||||
contract V1B {
|
||||
modifier modV1B() {
|
||||
_;
|
||||
}
|
||||
}
|
||||
==== Source: V2A ====
|
||||
pragma experimental ABIEncoderV2;
|
||||
import "X";
|
||||
|
||||
contract V2A {
|
||||
modifier modV2A() {
|
||||
X(0x00).get();
|
||||
_;
|
||||
}
|
||||
}
|
||||
==== Source: X ====
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
struct Data {
|
||||
bool flag;
|
||||
}
|
||||
|
||||
contract X {
|
||||
function get() public view returns (Data memory) {}
|
||||
}
|
||||
// ----
|
||||
@@ -8,4 +8,5 @@ contract test {
|
||||
}
|
||||
// ----
|
||||
// Warning 2519: (31-37): This declaration shadows an existing declaration.
|
||||
// Warning 2519: (39-45): This declaration shadows an existing declaration.
|
||||
// TypeError 6995: (159-160): Duplicate named argument "a".
|
||||
|
||||
@@ -8,4 +8,5 @@ contract test {
|
||||
}
|
||||
// ----
|
||||
// Warning 2519: (31-37): This declaration shadows an existing declaration.
|
||||
// Warning 2519: (39-45): This declaration shadows an existing declaration.
|
||||
// TypeError 6160: (153-158): Wrong argument count for function call: 0 arguments given but expected 2.
|
||||
|
||||
@@ -8,4 +8,5 @@ contract test {
|
||||
}
|
||||
// ----
|
||||
// Warning 2519: (31-37): This declaration shadows an existing declaration.
|
||||
// Warning 2519: (39-45): This declaration shadows an existing declaration.
|
||||
// TypeError 6160: (153-162): Wrong argument count for function call: 1 arguments given but expected 2.
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
==== Source: s1.sol ====
|
||||
import "s1.sol" as A;
|
||||
|
||||
library L {
|
||||
function f() internal pure {}
|
||||
}
|
||||
|
||||
contract C
|
||||
{
|
||||
function test() public pure {
|
||||
A.L;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 6133: (s1.sol:127-130): Statement has no effect.
|
||||
+1
@@ -5,5 +5,6 @@ contract test {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 2519: (57-63): This declaration shadows an existing declaration.
|
||||
// Warning 2072: (57-63): Unused local variable.
|
||||
// Warning 2072: (75-81): Unused local variable.
|
||||
|
||||
+1
-1
@@ -6,5 +6,5 @@ contract test {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 2519: (73-79): This declaration shadows an existing declaration.
|
||||
// DeclarationError 2333: (91-97): Identifier already declared.
|
||||
// Warning 2519: (73-79): This declaration shadows an existing declaration.
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
contract test {
|
||||
function e() external { }
|
||||
function f() public pure { uint e; e = 0; }
|
||||
function e(int) external { }
|
||||
}
|
||||
// ----
|
||||
// Warning 8760: (77-83): This declaration has the same name as another declaration.
|
||||
@@ -0,0 +1,10 @@
|
||||
function e() {}
|
||||
contract test {
|
||||
function f() pure public { uint e; uint g; uint h; e = g = h = 0; }
|
||||
function g() pure public {}
|
||||
}
|
||||
function h() {}
|
||||
// ----
|
||||
// Warning 2519: (63-69): This declaration shadows an existing declaration.
|
||||
// Warning 2519: (71-77): This declaration shadows an existing declaration.
|
||||
// Warning 2519: (79-85): This declaration shadows an existing declaration.
|
||||
Reference in New Issue
Block a user