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

This commit is contained in:
chriseth
2020-10-19 18:02:50 +02:00
125 changed files with 1187 additions and 404 deletions
@@ -0,0 +1,17 @@
contract C {
function f(bytes calldata x) public returns (C[] memory) {
return abi.decode(x, (C[]));
}
function g() public returns (bytes memory) {
C[] memory c = new C[](3);
c[0] = C(address(0x42));
c[1] = C(address(0x21));
c[2] = C(address(0x23));
return abi.encode(c);
}
}
// ====
// compileViaYul: also
// ----
// f(bytes): 0x20, 0xA0, 0x20, 3, 0x01, 0x02, 0x03 -> 0x20, 3, 0x01, 0x02, 0x03
// g() -> 0x20, 0xa0, 0x20, 3, 0x42, 0x21, 0x23
@@ -0,0 +1,20 @@
pragma experimental ABIEncoderV2;
contract C {
function f(bytes calldata x) public returns (C[] memory) {
return abi.decode(x, (C[]));
}
function g() public returns (bytes memory) {
C[] memory c = new C[](3);
c[0] = C(address(0x42));
c[1] = C(address(0x21));
c[2] = C(address(0x23));
return abi.encode(c);
}
}
// ====
// compileViaYul: also
// ----
// f(bytes): 0x20, 0xA0, 0x20, 3, 0x01, 0x02, 0x03 -> 0x20, 3, 0x01, 0x02, 0x03
// f(bytes): 0x20, 0x60, 0x20, 1, 0x0102030405060708090a0b0c0d0e0f1011121314 -> 0x20, 1, 0x0102030405060708090a0b0c0d0e0f1011121314
// f(bytes): 0x20, 0x60, 0x20, 1, 0x0102030405060708090a0b0c0d0e0f101112131415 -> FAILURE
// g() -> 0x20, 0xa0, 0x20, 3, 0x42, 0x21, 0x23
@@ -32,6 +32,7 @@ contract c {
data.push(bytes1(i));
}
data.pop();
data.pop();
assembly {
r := sload(data.slot)
}
@@ -42,4 +43,4 @@ contract c {
// ----
// test_short() -> 1780731860627700044960722568376587075150542249149356309979516913770823710
// test_long() -> 67
// test_pop() -> 1780731860627700044960722568376592200742329637303199754547598369979440702
// test_pop() -> 1780731860627700044960722568376592200742329637303199754547598369979433020
@@ -0,0 +1,37 @@
contract C {
bytes data;
function f() public returns (uint ret) {
data.push("a");
data.push("b");
delete data;
assembly {
ret := sload(data.slot)
}
}
function g() public returns (uint ret) {
assembly {
sstore(data.slot, 67)
}
data.push("a");
data.push("b");
assert(data.length == 35);
delete data;
assert(data.length == 0);
uint size = 999;
assembly {
size := sload(data.slot)
mstore(0, data.slot)
ret := sload(keccak256(0, 32))
}
assert(size == 0);
}
}
// ====
// compileViaYul: also
// ----
// f() -> 0
// g() -> 0
@@ -1,53 +0,0 @@
contract C {
uint256[1024] s;
function f() public returns (uint256 x) {
x = 42;
uint256 x0 = s[0];
uint256 x1 = s[1];
uint256 x2 = s[2];
uint256 x3 = s[3];
uint256 x4 = s[4];
uint256 x5 = s[5];
uint256 x6 = s[6];
uint256 x7 = s[7];
uint256 x8 = s[8];
uint256 x9 = s[9];
uint256 x10 = s[10];
uint256 x11 = s[11];
uint256 x12 = s[12];
uint256 x13 = s[13];
uint256 x14 = s[14];
uint256 x15 = s[15];
uint256 x16 = s[16];
uint256 x17 = s[17];
uint256 x18 = s[18];
s[1000] = x0 + 2;
s[118] = x18;
s[117] = x17;
s[116] = x16;
s[115] = x15;
s[114] = x14;
s[113] = x13;
s[112] = x12;
s[111] = x11;
s[110] = x10;
s[109] = x9;
s[108] = x8;
s[107] = x7;
s[106] = x6;
s[105] = x5;
s[104] = x4;
s[103] = x3;
s[102] = x2;
s[101] = x1;
s[100] = x0;
}
function test() public view returns(uint256) {
return s[1000];
}
}
// ====
// compileViaYul: true
// ----
// f() -> 0x2a
// test() -> 2
@@ -1,57 +0,0 @@
contract C {
uint256[1024] s;
function g() public returns (uint256) {
// try to prevent inlining
return f() + f() + f() + f() + f();
}
function f() public returns (uint256 x) {
x = 42;
uint256 x0 = s[0];
uint256 x1 = s[1];
uint256 x2 = s[2];
uint256 x3 = s[3];
uint256 x4 = s[4];
uint256 x5 = s[5];
uint256 x6 = s[6];
uint256 x7 = s[7];
uint256 x8 = s[8];
uint256 x9 = s[9];
uint256 x10 = s[10];
uint256 x11 = s[11];
uint256 x12 = s[12];
uint256 x13 = s[13];
uint256 x14 = s[14];
uint256 x15 = s[15];
uint256 x16 = s[16];
uint256 x17 = s[17];
uint256 x18 = s[18];
s[1000] = x0 + 2;
s[118] = x18;
s[117] = x17;
s[116] = x16;
s[115] = x15;
s[114] = x14;
s[113] = x13;
s[112] = x12;
s[111] = x11;
s[110] = x10;
s[109] = x9;
s[108] = x8;
s[107] = x7;
s[106] = x6;
s[105] = x5;
s[104] = x4;
s[103] = x3;
s[102] = x2;
s[101] = x1;
s[100] = x0;
}
function test() public view returns(uint256) {
return s[1000];
}
}
// ====
// compileViaYul: true
// ----
// f() -> 0x2a
// test() -> 2
@@ -0,0 +1,16 @@
pragma experimental SMTChecker;
contract C {
function f(bytes memory data) public pure {
bytes32 k = keccak256(data);
bytes32 s = sha256(data);
bytes32 r = ripemd160(data);
assert(k == s);
assert(s == r);
assert(r == k);
}
}
// ----
// Warning 6328: (183-197): CHC: Assertion violation happens here.
// Warning 6328: (201-215): CHC: Assertion violation happens here.
// Warning 6328: (219-233): CHC: Assertion violation happens here.
@@ -0,0 +1,32 @@
pragma experimental SMTChecker;
contract C {
function k(bytes memory b0, bytes memory b1) public pure {
bytes32 k0 = keccak256(b0);
bytes32 k1 = keccak256(b1);
assert(k0 == k1);
}
function s(bytes memory b0, bytes memory b1) public pure {
bytes32 s0 = sha256(b0);
bytes32 s1 = sha256(b1);
assert(s0 == s1);
}
function r(bytes memory b0, bytes memory b1) public pure {
bytes32 r0 = ripemd160(b0);
bytes32 r1 = ripemd160(b1);
assert(r0 == r1);
}
function e(bytes32 h0, uint8 v0, bytes32 r0, bytes32 s0, bytes32 h1, uint8 v1, bytes32 r1, bytes32 s1) public pure {
address a0 = ecrecover(h0, v0, r0, s0);
address a1 = ecrecover(h1, v1, r1, s1);
assert(a0 == a1);
}
}
// ----
// Warning 1218: (168-184): CHC: Error trying to invoke SMT solver.
// Warning 1218: (305-321): CHC: Error trying to invoke SMT solver.
// Warning 1218: (448-464): CHC: Error trying to invoke SMT solver.
// Warning 6328: (673-689): CHC: Assertion violation happens here.
// Warning 4661: (168-184): BMC: Assertion violation happens here.
// Warning 4661: (305-321): BMC: Assertion violation happens here.
// Warning 4661: (448-464): BMC: Assertion violation happens here.
@@ -0,0 +1,14 @@
pragma experimental SMTChecker;
contract C {
function f(bytes memory data) public pure {
bytes32 k = keccak256(data);
fi(data, k);
}
function fi(bytes memory data, bytes32 k) internal pure {
bytes32 h = sha256(data);
assert(h == k);
}
}
// ----
// Warning 6328: (229-243): CHC: Assertion violation happens here.
@@ -0,0 +1,12 @@
pragma experimental SMTChecker;
contract C {
function f(bytes memory data) public pure {
bytes32 k = keccak256(data);
fi(data, k);
}
function fi(bytes memory data, bytes32 k) internal pure {
bytes32 h = keccak256(data);
assert(h == k);
}
}
@@ -0,0 +1,38 @@
pragma experimental SMTChecker;
contract C {
bytes data;
bytes32 h;
uint8 v;
bytes32 r;
bytes32 s;
bytes32 kec;
bytes32 sha;
bytes32 rip;
address erc;
constructor(bytes memory _data, bytes32 _h, uint8 _v, bytes32 _r, bytes32 _s) {
data = _data;
h = _h;
v = _v;
r = _r;
s = _s;
kec = keccak256(data);
sha = sha256(data);
rip = ripemd160(data);
erc = ecrecover(h, v, r, s);
}
function f() public view {
bytes32 _kec = keccak256(data);
bytes32 _sha = sha256(data);
bytes32 _rip = ripemd160(data);
address _erc = ecrecover(h, v, r, s);
assert(_kec == kec);
assert(_sha == sha);
assert(_rip == rip);
assert(_erc == erc);
}
}
@@ -0,0 +1,54 @@
pragma experimental SMTChecker;
contract C {
bytes data;
bytes32 h;
uint8 v;
bytes32 r;
bytes32 s;
bytes32 kec;
bytes32 sha;
bytes32 rip;
address erc;
constructor(bytes memory _data, bytes32 _h, uint8 _v, bytes32 _r, bytes32 _s) {
data = _data;
h = _h;
v = _v;
r = _r;
s = _s;
kec = keccak256(data);
sha = sha256(data);
rip = ripemd160(data);
erc = ecrecover(h, v, r, s);
}
function set(bytes memory _data, bytes32 _h, uint8 _v, bytes32 _r, bytes32 _s) public {
data = _data;
h = _h;
v = _v;
r = _r;
s = _s;
}
function f() public view {
bytes32 _kec = keccak256(data);
bytes32 _sha = sha256(data);
bytes32 _rip = ripemd160(data);
address _erc = ecrecover(h, v, r, s);
assert(_kec == kec);
assert(_sha == sha);
assert(_rip == rip);
assert(_erc == erc);
}
}
// ----
// Warning 1218: (726-745): CHC: Error trying to invoke SMT solver.
// Warning 1218: (749-768): CHC: Error trying to invoke SMT solver.
// Warning 1218: (772-791): CHC: Error trying to invoke SMT solver.
// Warning 6328: (795-814): CHC: Assertion violation happens here.
// Warning 4661: (726-745): BMC: Assertion violation happens here.
// Warning 4661: (749-768): BMC: Assertion violation happens here.
// Warning 4661: (772-791): BMC: Assertion violation happens here.
@@ -0,0 +1,28 @@
pragma experimental SMTChecker;
contract C {
function k(bytes memory b0) public pure {
bytes memory b1 = b0;
bytes32 k0 = keccak256(b0);
bytes32 k1 = keccak256(b1);
assert(k0 == k1);
}
function s(bytes memory b0) public pure {
bytes memory b1 = b0;
bytes32 s0 = sha256(b0);
bytes32 s1 = sha256(b1);
assert(s0 == s1);
}
function r(bytes memory b0) public pure {
bytes memory b1 = b0;
bytes32 r0 = ripemd160(b0);
bytes32 r1 = ripemd160(b1);
assert(r0 == r1);
}
function e(bytes32 h0, uint8 v0, bytes32 r0, bytes32 s0) public pure {
(bytes32 h1, uint8 v1, bytes32 r1, bytes32 s1) = (h0, v0, r0, s0);
address a0 = ecrecover(h0, v0, r0, s0);
address a1 = ecrecover(h1, v1, r1, s1);
assert(a0 == a1);
}
}
@@ -12,7 +12,8 @@ contract Simple {
++x;
assert(x == 10);
}
assert(y == x);
// Removed because of Spacer nondeterminism.
//assert(y == x);
}
}
// ----
@@ -15,4 +15,3 @@ 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.
@@ -12,10 +12,5 @@ contract C {
}
}
// ----
// Warning 1218: (83-108): CHC: Error trying to invoke SMT solver.
// Warning 1218: (141-166): CHC: Error trying to invoke SMT solver.
// Warning 1218: (76-114): CHC: Error trying to invoke SMT solver.
// Warning 1218: (170-184): CHC: Error trying to invoke SMT solver.
// Warning 1218: (263-278): CHC: Error trying to invoke SMT solver.
// Warning 3046: (141-166): BMC: Division by zero happens here.
// Warning 3046: (263-278): BMC: Division by zero happens here.
@@ -9,8 +9,5 @@ contract C {
}
}
// ----
// Warning 1218: (118-143): CHC: Error trying to invoke SMT solver.
// Warning 1218: (183-208): CHC: Error trying to invoke SMT solver.
// Warning 1218: (219-233): CHC: Error trying to invoke SMT solver.
// Warning 6838: (93-143): BMC: Condition is always false.
// Warning 6838: (158-208): BMC: Condition is always false.
@@ -22,15 +22,5 @@ contract C {
}
// ----
// Warning 6321: (253-260): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
// Warning 1218: (94-109): CHC: Error trying to invoke SMT solver.
// Warning 1218: (113-126): CHC: Error trying to invoke SMT solver.
// Warning 1218: (180-195): CHC: Error trying to invoke SMT solver.
// Warning 1218: (199-212): CHC: Error trying to invoke SMT solver.
// Warning 1218: (275-290): CHC: Error trying to invoke SMT solver.
// Warning 1218: (303-318): CHC: Error trying to invoke SMT solver.
// Warning 1218: (349-364): CHC: Error trying to invoke SMT solver.
// Warning 1218: (377-392): CHC: Error trying to invoke SMT solver.
// Warning 1218: (322-336): CHC: Error trying to invoke SMT solver.
// Warning 1218: (396-410): CHC: Error trying to invoke SMT solver.
// Warning 3046: (94-109): BMC: Division by zero happens here.
// Warning 3046: (180-195): BMC: Division by zero happens here.
@@ -17,8 +17,3 @@ contract C {
}
}
// ----
// Warning 1218: (158-174): CHC: Error trying to invoke SMT solver.
// Warning 1218: (178-192): CHC: Error trying to invoke SMT solver.
// Warning 1218: (309-325): CHC: Error trying to invoke SMT solver.
// Warning 1218: (329-343): CHC: Error trying to invoke SMT solver.
// Warning 7812: (329-343): BMC: Assertion violation might happen here.
@@ -12,10 +12,5 @@ contract C {
}
}
// ----
// Warning 1218: (83-108): CHC: Error trying to invoke SMT solver.
// Warning 1218: (141-166): CHC: Error trying to invoke SMT solver.
// Warning 1218: (76-114): CHC: Error trying to invoke SMT solver.
// Warning 1218: (170-184): CHC: Error trying to invoke SMT solver.
// Warning 1218: (263-278): CHC: Error trying to invoke SMT solver.
// Warning 3046: (141-166): BMC: Division by zero happens here.
// Warning 3046: (263-278): BMC: Division by zero happens here.
@@ -9,6 +9,4 @@ contract C {
}
}
// ----
// Warning 1218: (129-143): CHC: Error trying to invoke SMT solver.
// Warning 1218: (147-161): CHC: Error trying to invoke SMT solver.
// Warning 4661: (147-161): BMC: Assertion violation happens here.
// Warning 6328: (147-161): CHC: Assertion violation happens here.
@@ -10,6 +10,4 @@ contract C {
}
}
// ----
// Warning 1218: (163-184): CHC: Error trying to invoke SMT solver.
// Warning 1218: (188-209): CHC: Error trying to invoke SMT solver.
// Warning 4661: (188-209): BMC: Assertion violation happens here.
// Warning 6328: (188-209): CHC: Assertion violation happens here.
@@ -10,6 +10,4 @@ contract C {
}
}
// ----
// Warning 1218: (171-190): CHC: Error trying to invoke SMT solver.
// Warning 1218: (194-213): CHC: Error trying to invoke SMT solver.
// Warning 4661: (194-213): BMC: Assertion violation happens here.
// Warning 6328: (194-213): CHC: Assertion violation happens here.
@@ -6,5 +6,4 @@ contract C {
}
}
// ----
// Warning 1218: (127-132): CHC: Error trying to invoke SMT solver.
// Warning 2661: (127-132): BMC: Overflow (resulting value larger than 0x80 * 2**248 - 1) happens here.
// Warning 4984: (127-132): CHC: Overflow (resulting value larger than 0x80 * 2**248 - 1) happens here.
@@ -7,4 +7,3 @@ contract C {
}
}
// ----
// Warning 1218: (147-152): CHC: Error trying to invoke SMT solver.
@@ -10,4 +10,3 @@ contract C {
}
}
// ----
// Warning 1218: (151-156): CHC: Error trying to invoke SMT solver.
@@ -12,4 +12,3 @@ contract C {
}
}
// ----
// Warning 1218: (265-270): CHC: Error trying to invoke SMT solver.
@@ -7,4 +7,3 @@ contract C {
}
}
// ----
// Warning 1218: (107-125): CHC: Error trying to invoke SMT solver.
@@ -7,5 +7,3 @@ contract C {
}
}
// ----
// Warning 1218: (112-117): CHC: Error trying to invoke SMT solver.
// Warning 1218: (105-123): CHC: Error trying to invoke SMT solver.
@@ -7,5 +7,3 @@ contract C {
}
}
// ----
// Warning 1218: (113-118): CHC: Error trying to invoke SMT solver.
// Warning 1218: (106-125): CHC: Error trying to invoke SMT solver.
@@ -7,5 +7,3 @@ contract C {
}
}
// ----
// Warning 1218: (113-118): CHC: Error trying to invoke SMT solver.
// Warning 1218: (106-125): CHC: Error trying to invoke SMT solver.
@@ -7,5 +7,3 @@ contract C {
}
}
// ----
// Warning 1218: (114-119): CHC: Error trying to invoke SMT solver.
// Warning 1218: (107-125): CHC: Error trying to invoke SMT solver.
@@ -9,4 +9,3 @@ contract C {
}
}
// ----
// Warning 1218: (166-182): CHC: Error trying to invoke SMT solver.
@@ -9,5 +9,3 @@ contract C
}
}
// ----
// Warning 1218: (113-118): CHC: Error trying to invoke SMT solver.
// Warning 1218: (122-142): CHC: Error trying to invoke SMT solver.
@@ -9,4 +9,3 @@ contract C
}
}
// ----
// Warning 1218: (126-139): CHC: Error trying to invoke SMT solver.
@@ -9,4 +9,3 @@ contract C
}
}
// ----
// Warning 1218: (130-149): CHC: Error trying to invoke SMT solver.
@@ -0,0 +1,12 @@
pragma experimental SMTChecker;
contract C {
function f(int x, int y) public pure {
require(y != 0);
require(x == 42);
int z1 = x % y;
int z2 = -x % y;
assert(z1 == -z2);
assert((x >= 0 && z1 >=0) || (x <= 0 && z1 <= 0));
}
}
// ----
@@ -6,6 +6,5 @@ contract C {
}
}
// ----
// Warning 1218: (110-115): CHC: Error trying to invoke SMT solver.
// Warning 4984: (110-115): CHC: Overflow (resulting value larger than 0x80 * 2**248 - 1) happens here.
// Warning 3046: (110-115): BMC: Division by zero happens here.
// Warning 2661: (110-115): BMC: Overflow (resulting value larger than 0x80 * 2**248 - 1) happens here.
@@ -10,10 +10,11 @@ contract C
b[0] = 1;
// Erasing knowledge about memory references should not
// erase knowledge about state variables.
assert(array[0] == 42);
// Removed because current Spacer seg faults.
//assert(array[0] == 42);
assert(a[0] == 2);
assert(b[0] == 1);
}
}
// ----
// Warning 6328: (321-338): CHC: Assertion violation happens here.
// Warning 6328: (371-388): CHC: Assertion violation happens here.
@@ -0,0 +1,8 @@
contract C {
function f() view public {
C[0];
}
}
// ----
// Warning 6133: (52-56): Statement has no effect.
// Warning 2018: (17-63): Function state mutability can be restricted to pure
@@ -1,7 +0,0 @@
contract C {
function f() view public {
C[0];
}
}
// ----
// TypeError 2876: (52-56): Index access for contracts or libraries is not possible.
@@ -0,0 +1,8 @@
library L {}
contract C {
function f() public {
L[] memory x;
}
}
// ----
// TypeError 1130: (51-52): Invalid use of a library name.
@@ -4,4 +4,4 @@ library C {
}
}
// ----
// TypeError 2876: (51-55): Index access for contracts or libraries is not possible.
// TypeError 2876: (51-55): Index access for library types and arrays of libraries are not possible.
@@ -0,0 +1,8 @@
library L {}
contract C {
function f() public pure {
new L[](2);
}
}
// ----
// TypeError 1130: (63-64): Invalid use of a library name.
@@ -0,0 +1,11 @@
library L {}
library M {}
contract C {
using L for M;
using M for L;
using L for L;
}
// ----
// TypeError 1130: (55-56): Invalid use of a library name.
// TypeError 1130: (74-75): Invalid use of a library name.
// TypeError 1130: (93-94): Invalid use of a library name.
@@ -0,0 +1,8 @@
library L {}
contract C {
function f() public pure {
new L();
}
}
// ----
// TypeError 1130: (63-64): Invalid use of a library name.
@@ -3,4 +3,3 @@ contract s{}
function f() {s[:][];}
// ----
// TypeError 1760: (53-57): Types cannot be sliced.
// TypeError 2876: (53-59): Index access for contracts or libraries is not possible.
@@ -0,0 +1,6 @@
library L {}
contract C {
function f() public override (L) {}
}
// ----
// TypeError 1130: (57-58): Invalid use of a library name.
@@ -6,5 +6,4 @@ contract test {
}
}
// ----
// TypeError 1273: (87-90): The type of a variable cannot be a library.
// TypeError 9582: (100-103): Member "l" not found or not visible after argument-dependent lookup in library L.
// TypeError 1130: (87-88): Invalid use of a library name.
@@ -1,6 +0,0 @@
library L {}
contract C {
function f() public {
new L();
}
}
@@ -9,6 +9,6 @@ contract Y {
}
}
// ----
// TypeError 1273: (29-34): The type of a variable cannot be a library.
// TypeError 1273: (50-57): The type of a variable cannot be a library.
// TypeError 1273: (77-82): The type of a variable cannot be a library.
// TypeError 1130: (29-30): Invalid use of a library name.
// TypeError 1130: (50-51): Invalid use of a library name.
// TypeError 1130: (77-78): Invalid use of a library name.
@@ -0,0 +1,5 @@
contract C {
function f(bytes calldata x) public pure returns (C[] memory c) {
c = abi.decode(x, (C[]));
}
}
@@ -1,4 +1,9 @@
library L {}
contract C { mapping(L => bool) i; }
contract C
{
mapping(bool => L) j;
mapping(L => bool) i;
}
// ----
// TypeError 1665: (34-35): Library types cannot be used as mapping keys.
// TypeError 1130: (44-45): Invalid use of a library name.
// TypeError 1130: (60-61): Invalid use of a library name.