Merge remote-tracking branch 'origin/develop' into HEAD

This commit is contained in:
chriseth
2020-10-28 18:19:31 +01:00
40 changed files with 642 additions and 146 deletions
@@ -1,16 +1,43 @@
pragma experimental ABIEncoderV2;
contract c {
uint256[][] a;
uint256[][] a1;
uint256[][2] a2;
uint256[2][] a3;
uint256[2][2] a4;
function test(uint256[][] calldata d) external returns (uint256, uint256) {
a = d;
assert(a[0][0] == d[0][0]);
assert(a[0][1] == d[0][1]);
return (a.length, a[1][0] + a[1][1]);
function test1(uint256[][] calldata c) external returns (uint256, uint256) {
a1 = c;
assert(a1[0][0] == c[0][0]);
assert(a1[0][1] == c[0][1]);
return (a1.length, a1[1][0] + a1[1][1]);
}
function test2(uint256[][2] calldata c) external returns (uint256, uint256) {
a2 = c;
assert(a2[0][0] == c[0][0]);
assert(a2[0][1] == c[0][1]);
return (a2[0].length, a2[1][0] + a2[1][1]);
}
function test3(uint256[2][] calldata c) external returns (uint256, uint256) {
a3 = c;
assert(a3[0][0] == c[0][0]);
assert(a3[0][1] == c[0][1]);
return (a3.length, a3[1][0] + a3[1][1]);
}
function test4(uint256[2][2] calldata c) external returns (uint256) {
a4 = c;
assert(a4[0][0] == c[0][0]);
assert(a4[0][1] == c[0][1]);
return (a4[1][0] + a4[1][1]);
}
}
// ====
// compileViaYul: true
// ----
// test(uint256[][]): 0x20, 2, 0x40, 0x40, 2, 23, 42 -> 2, 65
// test1(uint256[][]): 0x20, 2, 0x40, 0x40, 2, 23, 42 -> 2, 65
// test2(uint256[][2]): 0x20, 0x40, 0x40, 2, 23, 42 -> 2, 65
// test3(uint256[2][]): 0x20, 2, 0x40, 0x40, 23, 42 -> 2, 65
// test4(uint256[2][2]): 23, 42, 23, 42 -> 65
@@ -0,0 +1,20 @@
pragma experimental ABIEncoderV2;
contract C {
struct S {
uint128 p1;
uint256[][2] a;
uint32 p2;
}
S s;
function f(uint32 p1, S calldata c) external returns(uint32, uint128, uint256, uint256, uint32) {
s = c;
assert(s.a[0][0] == c.a[0][0]);
assert(s.a[1][1] == c.a[1][1]);
return (p1, s.p1, s.a[0][0], s.a[1][1], s.p2);
}
}
// ====
// compileViaYul: true
// ----
// f(uint32, (uint128, uint256[][2], uint32)): 55, 0x40, 77, 0x60, 88, 0x40, 0x40, 2, 1, 2 -> 55, 77, 1, 2, 88
@@ -0,0 +1,30 @@
pragma experimental SMTChecker;
contract A {
int x;
int y;
function a() public {
require(A.x < 100);
A.y = A.x++;
assert(A.y == A.x - 1);
// Fails
assert(A.y == 0);
A.y = ++A.x;
assert(A.y == A.x);
delete A.x;
assert(A.x == 0);
A.y = A.x--;
assert(A.y == A.x + 1);
assert(A.y == 0);
A.y = --A.x;
assert(A.y == A.x);
A.x += 10;
// Fails
assert(A.y == 0);
assert(A.y + 10 == A.x);
A.x -= 10;
assert(A.y == A.x);
}
}
// ----
// Warning 6328: (160-176): CHC: Assertion violation happens here.
// Warning 6328: (373-389): CHC: Assertion violation happens here.
@@ -0,0 +1,14 @@
pragma experimental SMTChecker;
contract A {
uint[] a;
function f() public {
A.a.push(2);
assert(A.a[A.a.length - 1] == 2);
A.a.pop();
// Fails
assert(A.a.length > 0);
assert(A.a.length == 0);
}
}
// ----
// Warning 6328: (156-178): CHC: Assertion violation happens here.
@@ -0,0 +1,31 @@
==== Source: AASource ====
pragma experimental SMTChecker;
import "AASource" as AA;
contract A {
int x;
int y;
function a() public {
require(A.x < 100);
AA.A.y = A.x++;
assert(A.y == AA.A.x - 1);
// Fails
assert(AA.A.y == 0);
A.y = ++AA.A.x;
assert(A.y == A.x);
delete AA.A.x;
assert(A.x == 0);
A.y = A.x--;
assert(AA.A.y == AA.A.x + 1);
A.y = --A.x;
assert(A.y == A.x);
AA.A.x += 10;
// Fails
assert(A.y == 0);
assert(A.y + 10 == A.x);
A.x -= 10;
assert(AA.A.y == A.x);
}
}
// ----
// Warning 6328: (AASource:191-210): CHC: Assertion violation happens here.
// Warning 6328: (AASource:402-418): CHC: Assertion violation happens here.
@@ -7,9 +7,7 @@ contract C {
function f(bool b) public {
if (b)
s.x[2] |= 1;
assert(s.x[2] != 1);
// Removed because of Spacer nondeterminism.
//assert(s.x[2] != 1);
}
}
// ----
// Warning 6328: (173-192): CHC: Assertion violation might happen here.
// Warning 7812: (173-192): BMC: Assertion violation might happen here.
@@ -0,0 +1,10 @@
pragma experimental SMTChecker;
contract C {
function f() public pure {
fixed x;
assert(x >>> 6 == 0);
}
}
// ----
// UnimplementedFeatureError: Not yet implemented - FixedPointType.
@@ -0,0 +1,11 @@
pragma experimental SMTChecker;
contract C {
function f(bool x) public pure {
(uint a, uint b) = x ? (10000000001, 2) : (3, 4);
assert(a != 0);
assert(b != 0);
assert(a % 2 == 1);
assert(b % 2 == 0);
}
}
@@ -17,7 +17,8 @@ contract C
// Should not fail since knowledge is erased only for mapping (uint => uint).
assert(severalMaps8[0][0] == 42);
// Should not fail since singleMap == severalMaps3d[0][0] is not possible.
assert(severalMaps3d[0][0][0] == 42);
// Removed because of Spacer nondeterminism.
//assert(severalMaps3d[0][0][0] == 42);
// Should fail since singleMap == map is possible.
assert(map[0] == 42);
}
@@ -26,4 +27,4 @@ contract C
}
}
// ----
// Warning 6328: (781-801): CHC: Assertion violation happens here.
// Warning 6328: (830-850): CHC: Assertion violation happens here.
@@ -14,7 +14,7 @@ contract C {
// ====
// EVMVersion: =homestead
// ----
// TypeError 7756: (86-100): The "returndatasize" instruction is only available for Byzantium-compatible VMs (you are currently compiling for "homestead").
// TypeError 4778: (86-100): The "returndatasize" instruction is only available for Byzantium-compatible VMs (you are currently compiling for "homestead").
// DeclarationError 3812: (77-102): Variable count mismatch: 1 variables and 0 values.
// TypeError 7756: (115-129): The "returndatacopy" instruction is only available for Byzantium-compatible VMs (you are currently compiling for "homestead").
// TypeError 1503: (245-255): The "staticcall" instruction is only available for Byzantium-compatible VMs (you are currently compiling for "homestead").
@@ -17,9 +17,9 @@ contract C {
// ----
// TypeError 6612: (103-106): The "shl" instruction is only available for Constantinople-compatible VMs (you are currently compiling for "byzantium").
// DeclarationError 8678: (96-116): Variable count does not match number of values (1 vs. 0)
// TypeError 6612: (136-139): The "shr" instruction is only available for Constantinople-compatible VMs (you are currently compiling for "byzantium").
// TypeError 7458: (136-139): The "shr" instruction is only available for Constantinople-compatible VMs (you are currently compiling for "byzantium").
// DeclarationError 8678: (129-147): Variable count does not match number of values (1 vs. 0)
// TypeError 6612: (167-170): The "sar" instruction is only available for Constantinople-compatible VMs (you are currently compiling for "byzantium").
// TypeError 2054: (167-170): The "sar" instruction is only available for Constantinople-compatible VMs (you are currently compiling for "byzantium").
// DeclarationError 8678: (160-178): Variable count does not match number of values (1 vs. 0)
// TypeError 6166: (283-290): The "create2" instruction is only available for Constantinople-compatible VMs (you are currently compiling for "byzantium").
// DeclarationError 8678: (276-302): Variable count does not match number of values (1 vs. 0)