mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #10033 from ethereum/develop
Merge develop into breaking
This commit is contained in:
@@ -14,9 +14,9 @@ contract C {
|
||||
}
|
||||
// ----
|
||||
// creation:
|
||||
// codeDepositCost: 1106800
|
||||
// executionCost: 1147
|
||||
// totalCost: 1107947
|
||||
// codeDepositCost: 1107400
|
||||
// executionCost: 1154
|
||||
// totalCost: 1108554
|
||||
// external:
|
||||
// a(): 1130
|
||||
// b(uint256): infinite
|
||||
|
||||
@@ -17,9 +17,9 @@ contract C {
|
||||
// optimize-yul: true
|
||||
// ----
|
||||
// creation:
|
||||
// codeDepositCost: 604400
|
||||
// codeDepositCost: 605000
|
||||
// executionCost: 638
|
||||
// totalCost: 605038
|
||||
// totalCost: 605638
|
||||
// external:
|
||||
// a(): 1029
|
||||
// b(uint256): 2084
|
||||
|
||||
@@ -24,9 +24,9 @@ contract Large {
|
||||
}
|
||||
// ----
|
||||
// creation:
|
||||
// codeDepositCost: 637000
|
||||
// codeDepositCost: 637600
|
||||
// executionCost: 670
|
||||
// totalCost: 637670
|
||||
// totalCost: 638270
|
||||
// external:
|
||||
// a(): 1051
|
||||
// b(uint256): 2046
|
||||
|
||||
@@ -27,9 +27,9 @@ contract Large {
|
||||
// optimize-runs: 2
|
||||
// ----
|
||||
// creation:
|
||||
// codeDepositCost: 260600
|
||||
// codeDepositCost: 261200
|
||||
// executionCost: 300
|
||||
// totalCost: 260900
|
||||
// totalCost: 261500
|
||||
// external:
|
||||
// a(): 998
|
||||
// b(uint256): 2305
|
||||
|
||||
@@ -11,9 +11,9 @@ contract Medium {
|
||||
}
|
||||
// ----
|
||||
// creation:
|
||||
// codeDepositCost: 253200
|
||||
// codeDepositCost: 253800
|
||||
// executionCost: 294
|
||||
// totalCost: 253494
|
||||
// totalCost: 254094
|
||||
// external:
|
||||
// a(): 1028
|
||||
// b(uint256): 2046
|
||||
|
||||
@@ -14,9 +14,9 @@ contract Medium {
|
||||
// optimize-runs: 2
|
||||
// ----
|
||||
// creation:
|
||||
// codeDepositCost: 141000
|
||||
// codeDepositCost: 141600
|
||||
// executionCost: 190
|
||||
// totalCost: 141190
|
||||
// totalCost: 141790
|
||||
// external:
|
||||
// a(): 998
|
||||
// b(uint256): 2063
|
||||
|
||||
@@ -6,9 +6,9 @@ contract Small {
|
||||
}
|
||||
// ----
|
||||
// creation:
|
||||
// codeDepositCost: 84800
|
||||
// codeDepositCost: 85400
|
||||
// executionCost: 135
|
||||
// totalCost: 84935
|
||||
// totalCost: 85535
|
||||
// external:
|
||||
// fallback: 129
|
||||
// a(): 983
|
||||
|
||||
@@ -9,9 +9,9 @@ contract Small {
|
||||
// optimize-runs: 2
|
||||
// ----
|
||||
// creation:
|
||||
// codeDepositCost: 60600
|
||||
// codeDepositCost: 61200
|
||||
// executionCost: 111
|
||||
// totalCost: 60711
|
||||
// totalCost: 61311
|
||||
// external:
|
||||
// fallback: 118
|
||||
// a(): 976
|
||||
|
||||
@@ -15,7 +15,8 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// EVMVersion: >homestead
|
||||
// ----
|
||||
// h(uint256[2][]) : 0x20, 3, 123, 124, 223, 224, 323, 324 -> 32, 256, 0x20, 3, 123, 124, 223, 224, 323, 324
|
||||
// h(uint256[2][]): 0x20, 3, 123, 124, 223, 224, 323, 324 -> 32, 256, 0x20, 3, 123, 124, 223, 224, 323, 324
|
||||
// i(uint256[2][2]): 123, 124, 223, 224 -> 32, 128, 123, 124, 223, 224
|
||||
|
||||
@@ -19,5 +19,7 @@ contract C {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() -> true
|
||||
|
||||
@@ -44,5 +44,7 @@ contract C {
|
||||
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() -> true
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
contract C {
|
||||
uint[] a;
|
||||
function f() public returns (uint, uint) {
|
||||
uint[] memory b = new uint[](3);
|
||||
b[0] = 1;
|
||||
a = b;
|
||||
return (a[0], a.length);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// f() -> 1, 3
|
||||
@@ -10,6 +10,8 @@ contract Test {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// set(uint24[3][]): 0x20, 0x06, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12 -> 0x06
|
||||
// data(uint256,uint256): 0x02, 0x02 -> 0x09
|
||||
|
||||
@@ -14,6 +14,5 @@ contract c {
|
||||
uint8(data[97]) == 97;
|
||||
}
|
||||
}
|
||||
|
||||
// ----
|
||||
// test1() -> true
|
||||
|
||||
@@ -10,7 +10,6 @@ contract c {
|
||||
|
||||
bytes data;
|
||||
}
|
||||
|
||||
// ----
|
||||
// getLength() -> 0
|
||||
// set(): 1, 2 -> true
|
||||
|
||||
@@ -7,6 +7,8 @@ contract C {
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// constructor(): 1, 2, 3 ->
|
||||
// a(uint256): 0 -> 1
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
contract C {
|
||||
uint256[] x;
|
||||
function f() public returns(uint256) {
|
||||
x.push(42); x.push(42); x.push(42); x.push(42);
|
||||
uint256[] memory y = new uint256[](1);
|
||||
y[0] = 23;
|
||||
x = y;
|
||||
assembly { sstore(x.slot, 4) }
|
||||
assert(x[1] == 0);
|
||||
assert(x[2] == 0);
|
||||
return x[3];
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() -> 0
|
||||
@@ -0,0 +1,46 @@
|
||||
contract C {
|
||||
uint128[] x;
|
||||
uint64[] x1;
|
||||
uint120[] x2;
|
||||
function f() public returns(uint128) {
|
||||
x.push(42); x.push(42); x.push(42); x.push(42);
|
||||
uint128[] memory y = new uint128[](1);
|
||||
y[0] = 23;
|
||||
x = y;
|
||||
assembly { sstore(x.slot, 4) }
|
||||
assert(x[0] == 23);
|
||||
assert(x[2] == 0);
|
||||
assert(x[3] == 0);
|
||||
return x[1];
|
||||
}
|
||||
|
||||
function g() public returns(uint64) {
|
||||
x1.push(42); x1.push(42); x1.push(42); x1.push(42);
|
||||
uint64[] memory y = new uint64[](1);
|
||||
y[0] = 23;
|
||||
x1 = y;
|
||||
assembly { sstore(x1.slot, 4) }
|
||||
assert(x1[0] == 23);
|
||||
assert(x1[2] == 0);
|
||||
assert(x1[3] == 0);
|
||||
return x1[1];
|
||||
}
|
||||
|
||||
function h() public returns(uint120) {
|
||||
x2.push(42); x2.push(42); x2.push(42); x2.push(42);
|
||||
uint120[] memory y = new uint120[](1);
|
||||
y[0] = 23;
|
||||
x2 = y;
|
||||
assembly { sstore(x2.slot, 4) }
|
||||
assert(x2[0] == 23);
|
||||
assert(x2[2] == 0);
|
||||
assert(x2[3] == 0);
|
||||
return x2[1];
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: true
|
||||
// ----
|
||||
// f() -> 0
|
||||
// g() -> 0
|
||||
// h() -> 0
|
||||
@@ -0,0 +1,30 @@
|
||||
contract C {
|
||||
uint128[13] unused;
|
||||
uint32[] a;
|
||||
uint32[3] b;
|
||||
function f() public returns (uint32, uint256) {
|
||||
uint32[] memory m = new uint32[](3);
|
||||
m[0] = 1;
|
||||
m[1] = 2;
|
||||
m[2] = 3;
|
||||
a = m;
|
||||
assert(a[0] == m[0]);
|
||||
assert(a[1] == m[1]);
|
||||
assert(a[2] == m[2]);
|
||||
return (a[0], a.length);
|
||||
}
|
||||
function g() public returns (uint32, uint32, uint32) {
|
||||
uint32[3] memory m;
|
||||
m[0] = 1; m[1] = 2; m[2] = 3;
|
||||
a = m;
|
||||
b = m;
|
||||
assert(a[0] == b[0] && a[1] == b[1] && a[2] == b[2]);
|
||||
assert(a.length == b.length);
|
||||
return (a[0], b[1], a[2]);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() -> 1, 3
|
||||
// g() -> 1, 2, 3
|
||||
@@ -0,0 +1,16 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract c {
|
||||
uint256[][] a;
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: true
|
||||
// ----
|
||||
// test(uint256[][]): 0x20, 2, 0x40, 0x40, 2, 23, 42 -> 2, 65
|
||||
@@ -0,0 +1,45 @@
|
||||
contract Test {
|
||||
uint128[13] unused;
|
||||
uint256[][] a;
|
||||
uint256[4][] b;
|
||||
uint256[2][3] c;
|
||||
|
||||
function test() external returns (uint256) {
|
||||
uint256[][] memory m = new uint256[][](2);
|
||||
m[0] = new uint256[](3);
|
||||
m[0][0] = 7; m[0][1] = 8; m[0][2] = 9;
|
||||
m[1] = new uint256[](4);
|
||||
m[1][1] = 7; m[1][2] = 8; m[1][3] = 9;
|
||||
a = m;
|
||||
return a[0][0] + a[0][1] + a[1][3];
|
||||
}
|
||||
|
||||
function test1() external returns (uint256) {
|
||||
uint256[2][] memory m = new uint256[2][](1);
|
||||
m[0][0] = 1; m[0][1] = 2;
|
||||
b = m;
|
||||
return b[0][0] + b[0][1];
|
||||
}
|
||||
|
||||
function test2() external returns (uint256) {
|
||||
uint256[2][2] memory m;
|
||||
m[0][0] = 1; m[1][1] = 2; m[0][1] = 3;
|
||||
c = m;
|
||||
return c[0][0] + c[1][1] + c[0][1];
|
||||
}
|
||||
|
||||
function test3() external returns (uint256) {
|
||||
uint256[2][3] memory m;
|
||||
m[0][0] = 7; m[1][0] = 8; m[2][0] = 9;
|
||||
m[0][1] = 7; m[1][1] = 8; m[2][1] = 9;
|
||||
a = m;
|
||||
return a[0][0] + a[1][0] + a[2][1];
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// test() -> 24
|
||||
// test1() -> 3
|
||||
// test2() -> 6
|
||||
// test3() -> 24
|
||||
@@ -0,0 +1,19 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract C {
|
||||
struct S {
|
||||
uint128 a;
|
||||
uint64 b;
|
||||
uint128 c;
|
||||
}
|
||||
uint128[137] unused;
|
||||
S[] s;
|
||||
function f(S[] calldata c) public returns (uint128, uint64, uint128) {
|
||||
s = c;
|
||||
return (s[2].a, s[1].b, s[0].c);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: true
|
||||
// ----
|
||||
// f((uint128, uint64, uint128)[]): 0x20, 3, 0, 0, 12, 0, 11, 0, 10, 0, 0 -> 10, 11, 12
|
||||
@@ -0,0 +1,21 @@
|
||||
contract C {
|
||||
struct S {
|
||||
uint128 a;
|
||||
uint64 b;
|
||||
uint128 c;
|
||||
}
|
||||
uint128[137] unused;
|
||||
S[] s;
|
||||
function f() public returns (uint128, uint64, uint128) {
|
||||
S[] memory m = new S[](3);
|
||||
m[2].a = 10;
|
||||
m[1].b = 11;
|
||||
m[0].c = 12;
|
||||
s = m;
|
||||
return (s[2].a, s[1].b, s[0].c);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: true
|
||||
// ----
|
||||
// f() -> 10, 11, 12
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract C {
|
||||
struct S {
|
||||
uint256[] a;
|
||||
}
|
||||
|
||||
S[] s;
|
||||
|
||||
function f(S[] calldata c) external returns (uint256, uint256) {
|
||||
s = c;
|
||||
return (s[1].a.length, s[1].a[0]);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: true
|
||||
// ----
|
||||
// f((uint256[])[]): 0x20, 3, 0x60, 0x60, 0x60, 0x20, 3, 1, 2, 3 -> 3, 1
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract C {
|
||||
struct S {
|
||||
uint136 p;
|
||||
uint128[3] b;
|
||||
uint128[] c;
|
||||
}
|
||||
|
||||
S[] s;
|
||||
|
||||
function f() external returns (uint256, uint256, uint128, uint128) {
|
||||
S[] memory m = new S[](3);
|
||||
m[1] = S(0, [uint128(1), 2, 3], new uint128[](3));
|
||||
m[1].c[0] = 1;
|
||||
m[1].c[1] = 2;
|
||||
m[1].c[2] = 3;
|
||||
s = m;
|
||||
assert(s.length == m.length);
|
||||
assert(s[1].b[1] == m[1].b[1]);
|
||||
assert(s[1].c[0] == m[1].c[0]);
|
||||
return (s[1].b.length, s[1].c.length, s[1].b[2], s[1].c[0]);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: true
|
||||
// ----
|
||||
// f() -> 3, 3, 3, 1
|
||||
@@ -0,0 +1,13 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract C {
|
||||
uint256[] s;
|
||||
function f(uint256[] calldata data) external returns (uint) {
|
||||
s = data;
|
||||
return s[0];
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(uint256[]): 0x20, 0x03, 0x1, 0x2, 0x3 -> 0x1
|
||||
@@ -11,6 +11,8 @@ contract C {
|
||||
return uint256(uint8(data[0][4]));
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(bytes32): "789" -> "9"
|
||||
// g(bytes32): "789" -> 0x35
|
||||
|
||||
@@ -11,5 +11,7 @@ contract C {
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() -> 1, 2, 3, 4, 5
|
||||
|
||||
@@ -8,6 +8,8 @@ contract C {
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// constructor(): 1, 2, 3, 4 ->
|
||||
// a() -> 1
|
||||
|
||||
@@ -22,6 +22,8 @@ contract test {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(bool): true -> 1
|
||||
// f(bool): false -> 2
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
library Lib {
|
||||
struct Items {
|
||||
mapping (uint => uint) a;
|
||||
}
|
||||
|
||||
function get() public returns (Items storage x) {
|
||||
assembly { x.slot := 123 }
|
||||
}
|
||||
}
|
||||
|
||||
contract C {
|
||||
function f() public returns(uint256 slot) {
|
||||
Lib.Items storage ptr = Lib.get();
|
||||
assembly { slot := ptr.slot }
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// library: Lib
|
||||
// f() -> 123
|
||||
@@ -22,6 +22,8 @@ contract test {
|
||||
multiple_map[2][1][2].finalArray[3] = 5;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// data(uint256): 0 -> 8
|
||||
// data(uint256): 8 -> FAILURE
|
||||
|
||||
@@ -19,6 +19,8 @@ contract Test {
|
||||
return z;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// x(uint256): 0 -> -1
|
||||
// x(uint256): 1 -> -2
|
||||
|
||||
@@ -26,5 +26,7 @@ contract C {
|
||||
x2 = s.s3.x2;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// get() -> 0x01, 0x00, 0x09, 0x00, 0x04, 0x05
|
||||
|
||||
@@ -8,7 +8,6 @@ contract C {
|
||||
|
||||
bytes savedData;
|
||||
}
|
||||
|
||||
// ----
|
||||
// save() -> 24 # empty copy loop #
|
||||
// save(): "abcdefg" -> 24
|
||||
|
||||
@@ -14,10 +14,10 @@ contract C {
|
||||
// Safe but knowledge about `c` is erased because `b` could be pointing to `c[x][y]`.
|
||||
assert(c[0][0][0] == 12);
|
||||
// Safe but knowledge about `d` is erased because `b` could be pointing to `d`.
|
||||
assert(d[5] == 7);
|
||||
// Removed assertion because current Spacer seg faults in cex generation.
|
||||
//assert(d[5] == 7);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 6328: (193-217): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (309-333): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (419-436): CHC: Assertion violation happens here.
|
||||
|
||||
@@ -13,8 +13,8 @@ contract C {
|
||||
// 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);
|
||||
// Removed because current Spacer seg faults in cex generation.
|
||||
//assert(address(this).balance == t);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 6328: (496-530): CHC: Assertion violation happens here.
|
||||
|
||||
@@ -20,9 +20,10 @@ contract C {
|
||||
|
||||
function f() public {
|
||||
uint oldX = x;
|
||||
d.d();
|
||||
// Removed because Spacer 4.8.9 seg faults.
|
||||
//d.d();
|
||||
assert(oldX == x);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 6328: (286-303): CHC: Assertion violation happens here.
|
||||
// Warning 2018: (236-355): Function state mutability can be restricted to view
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
pragma experimental SMTChecker;
|
||||
|
||||
contract C {
|
||||
uint y;
|
||||
function c(uint _y) public returns (uint) {
|
||||
y = _y;
|
||||
return y;
|
||||
}
|
||||
}
|
||||
|
||||
contract B is C {
|
||||
function b() public returns (uint) { return c(42); }
|
||||
}
|
||||
|
||||
contract A is B {
|
||||
uint public x;
|
||||
|
||||
function a() public {
|
||||
x = b();
|
||||
assert(x < 40);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 6328: (274-288): CHC: Assertion violation happens here.
|
||||
@@ -13,3 +13,4 @@ contract Simple {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 4661: (187-201): BMC: Assertion violation happens here.
|
||||
|
||||
@@ -25,10 +25,10 @@ contract C {
|
||||
|
||||
// Fails due to j.
|
||||
function i() public view {
|
||||
assert(x < 2);
|
||||
// Disabled because Spacer 4.8.9 seg faults.
|
||||
//assert(x < 2);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTSolvers: z3
|
||||
// ----
|
||||
// Warning 6328: (311-324): CHC: Assertion violation happens here.
|
||||
|
||||
@@ -9,12 +9,12 @@ contract LoopFor2 {
|
||||
b[i] = i + 1;
|
||||
c[i] = b[i];
|
||||
}
|
||||
assert(b[0] == c[0]);
|
||||
// Removed because current Spacer seg faults in cex generation.
|
||||
//assert(b[0] == c[0]);
|
||||
assert(a[0] == 900);
|
||||
assert(b[0] == 900);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 6328: (281-301): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (305-324): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (328-347): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (373-392): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (396-415): CHC: Assertion violation happens here.
|
||||
|
||||
@@ -11,13 +11,12 @@ contract LoopFor2 {
|
||||
b[i] = i + 1;
|
||||
c[i] = b[i];
|
||||
}
|
||||
assert(b[0] == c[0]);
|
||||
assert(a[0] == 900);
|
||||
assert(b[0] == 900);
|
||||
// Removed because current Spacer seg faults in cex generation.
|
||||
//assert(b[0] == c[0]);
|
||||
//assert(a[0] == 900);
|
||||
//assert(b[0] == 900);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTSolvers: z3
|
||||
// ----
|
||||
// Warning 6328: (274-294): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (321-340): CHC: Assertion violation happens here.
|
||||
|
||||
+4
-4
@@ -11,7 +11,8 @@ contract LoopFor2 {
|
||||
c[i] = b[i];
|
||||
++i;
|
||||
}
|
||||
assert(b[0] == c[0]);
|
||||
// Removed because current Spacer seg faults in cex generation.
|
||||
//assert(b[0] == c[0]);
|
||||
assert(a[0] == 900);
|
||||
assert(b[0] == 900);
|
||||
}
|
||||
@@ -19,6 +20,5 @@ contract LoopFor2 {
|
||||
// ====
|
||||
// SMTSolvers: z3
|
||||
// ----
|
||||
// Warning 6328: (281-301): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (305-324): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (328-347): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (373-392): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (396-415): CHC: Assertion violation happens here.
|
||||
|
||||
+4
-4
@@ -15,13 +15,13 @@ contract LoopFor2 {
|
||||
}
|
||||
// Fails due to aliasing, since both b and c are
|
||||
// memory references of same type.
|
||||
assert(b[0] == c[0]);
|
||||
// Removed because current Spacer seg faults in cex generation.
|
||||
//assert(b[0] == c[0]);
|
||||
assert(a[0] == 900);
|
||||
assert(b[0] == 900);
|
||||
// Removed because current Spacer seg faults in cex generation.
|
||||
//assert(b[0] == 900);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTSolvers: z3
|
||||
// ----
|
||||
// Warning 6328: (362-382): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (409-428): CHC: Assertion violation happens here.
|
||||
|
||||
-1
@@ -34,5 +34,4 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 6328: (516-534): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (573-587): CHC: Assertion violation happens here.
|
||||
|
||||
@@ -13,9 +13,9 @@ contract C {
|
||||
d.d();
|
||||
return x;
|
||||
}
|
||||
function f(bool b) public {
|
||||
function f() public {
|
||||
x = 1;
|
||||
uint y = b ? g() : 3;
|
||||
uint y = g();
|
||||
assert(x == 2 || x == 1);
|
||||
}
|
||||
function h() public {
|
||||
@@ -23,5 +23,5 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 2072: (288-294): Unused local variable.
|
||||
// Warning 6328: (318-342): CHC: Assertion violation happens here.
|
||||
// Warning 2072: (282-288): Unused local variable.
|
||||
// Warning 6328: (304-328): CHC: Assertion violation happens here.
|
||||
|
||||
@@ -17,7 +17,8 @@ contract C {
|
||||
b[x][y] = v;
|
||||
delete b[x];
|
||||
// Not necessarily the case.
|
||||
assert(b[y][x] == 0);
|
||||
// Removed because current Spacer seg faults in cex generation.
|
||||
//assert(b[y][x] == 0);
|
||||
}
|
||||
function i(uint x, uint y, uint v) public {
|
||||
b[x][y] = v;
|
||||
@@ -38,5 +39,4 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 6328: (372-392): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (617-637): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (685-705): CHC: Assertion violation happens here.
|
||||
|
||||
@@ -12,4 +12,3 @@ contract C
|
||||
// ----
|
||||
// Warning 6328: (85-109): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (113-137): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (155-191): CHC: Assertion violation happens here.
|
||||
|
||||
@@ -4,7 +4,23 @@ contract C
|
||||
{
|
||||
function f() public payable {
|
||||
assert(msg.data.length > 0);
|
||||
// Fails since calldata size should be 4
|
||||
assert(msg.data.length > 4);
|
||||
// f's sig is 0x26121ff0
|
||||
assert(msg.data[0] == 0x26);
|
||||
assert(msg.data[1] == 0x12);
|
||||
assert(msg.data[2] == 0x1f);
|
||||
assert(msg.data[3] == 0xf0);
|
||||
}
|
||||
function g() public payable {
|
||||
// g's sig is 0xe2179b8e
|
||||
assert(msg.data[0] == 0xe2);
|
||||
assert(msg.data[1] == 0x17);
|
||||
assert(msg.data[2] == 0x9b);
|
||||
// Fails
|
||||
assert(msg.data[3] == 0x8f);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 6328: (79-106): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (153-180): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (500-527): CHC: Assertion violation happens here.
|
||||
|
||||
@@ -2,9 +2,29 @@ pragma experimental SMTChecker;
|
||||
|
||||
contract C
|
||||
{
|
||||
function f() public payable {
|
||||
function f() public pure {
|
||||
assert(msg.sig == 0x00000000);
|
||||
assert(msg.sig == 0x26121ff0);
|
||||
fi();
|
||||
gi();
|
||||
}
|
||||
function fi() internal pure {
|
||||
assert(msg.sig == 0x26121ff0);
|
||||
}
|
||||
function g() public pure {
|
||||
assert(msg.sig == 0xe2179b8e);
|
||||
gi();
|
||||
}
|
||||
function gi() internal pure {
|
||||
// Fails since f can also call gi in which case msg.sig == 0x26121ff0
|
||||
assert(msg.sig == 0xe2179b8e);
|
||||
}
|
||||
function h() public pure {
|
||||
// Fails since gi can also call h in which case msg.sig can be f() or g()
|
||||
assert(msg.sig == 0xe2179b8e);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 6328: (79-108): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (76-105): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (403-432): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (543-572): CHC: Assertion violation happens here.
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
pragma experimental SMTChecker;
|
||||
|
||||
contract C {
|
||||
uint gleft;
|
||||
|
||||
function f() public payable {
|
||||
gleft = gasleft();
|
||||
|
||||
fi();
|
||||
|
||||
assert(gleft == gasleft());
|
||||
assert(gleft >= gasleft());
|
||||
}
|
||||
|
||||
function fi() internal view {
|
||||
assert(gleft == gasleft());
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 6328: (124-150): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (219-245): CHC: Assertion violation happens here.
|
||||
@@ -0,0 +1,61 @@
|
||||
pragma experimental SMTChecker;
|
||||
|
||||
contract C {
|
||||
bytes32 bhash;
|
||||
address coin;
|
||||
uint dif;
|
||||
uint glimit;
|
||||
uint number;
|
||||
uint tstamp;
|
||||
bytes mdata;
|
||||
address sender;
|
||||
bytes4 sig;
|
||||
uint value;
|
||||
uint gprice;
|
||||
address origin;
|
||||
|
||||
function f() public payable {
|
||||
bhash = blockhash(12);
|
||||
coin = block.coinbase;
|
||||
dif = block.difficulty;
|
||||
glimit = block.gaslimit;
|
||||
number = block.number;
|
||||
tstamp = block.timestamp;
|
||||
mdata = msg.data;
|
||||
sender = msg.sender;
|
||||
sig = msg.sig;
|
||||
value = msg.value;
|
||||
gprice = tx.gasprice;
|
||||
origin = tx.origin;
|
||||
|
||||
fi();
|
||||
|
||||
assert(bhash == blockhash(12));
|
||||
assert(coin == block.coinbase);
|
||||
assert(dif == block.difficulty);
|
||||
assert(glimit == block.gaslimit);
|
||||
assert(number == block.number);
|
||||
assert(tstamp == block.timestamp);
|
||||
assert(mdata.length == msg.data.length);
|
||||
assert(sender == msg.sender);
|
||||
assert(sig == msg.sig);
|
||||
assert(value == msg.value);
|
||||
assert(gprice == tx.gasprice);
|
||||
assert(origin == tx.origin);
|
||||
}
|
||||
|
||||
function fi() internal view {
|
||||
assert(bhash == blockhash(12));
|
||||
assert(coin == block.coinbase);
|
||||
assert(dif == block.difficulty);
|
||||
assert(glimit == block.gaslimit);
|
||||
assert(number == block.number);
|
||||
assert(tstamp == block.timestamp);
|
||||
assert(mdata.length == msg.data.length);
|
||||
assert(sender == msg.sender);
|
||||
assert(sig == msg.sig);
|
||||
assert(value == msg.value);
|
||||
assert(gprice == tx.gasprice);
|
||||
assert(origin == tx.origin);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
pragma experimental SMTChecker;
|
||||
|
||||
contract C {
|
||||
bytes32 bhash;
|
||||
address coin;
|
||||
uint dif;
|
||||
uint glimit;
|
||||
uint number;
|
||||
uint tstamp;
|
||||
bytes mdata;
|
||||
address sender;
|
||||
bytes4 sig;
|
||||
uint value;
|
||||
uint gprice;
|
||||
address origin;
|
||||
|
||||
function f() public payable {
|
||||
bhash = blockhash(12);
|
||||
coin = block.coinbase;
|
||||
dif = block.difficulty;
|
||||
glimit = block.gaslimit;
|
||||
number = block.number;
|
||||
tstamp = block.timestamp;
|
||||
mdata = msg.data;
|
||||
sender = msg.sender;
|
||||
sig = msg.sig;
|
||||
value = msg.value;
|
||||
gprice = tx.gasprice;
|
||||
origin = tx.origin;
|
||||
|
||||
fi();
|
||||
|
||||
assert(bhash == blockhash(122));
|
||||
assert(coin != block.coinbase);
|
||||
assert(dif != block.difficulty);
|
||||
assert(glimit != block.gaslimit);
|
||||
assert(number != block.number);
|
||||
assert(tstamp != block.timestamp);
|
||||
assert(mdata.length != msg.data.length);
|
||||
assert(sender != msg.sender);
|
||||
assert(sig != msg.sig);
|
||||
assert(value != msg.value);
|
||||
assert(gprice != tx.gasprice);
|
||||
assert(origin != tx.origin);
|
||||
}
|
||||
|
||||
function fi() internal view {
|
||||
assert(bhash == blockhash(122));
|
||||
assert(coin != block.coinbase);
|
||||
assert(dif != block.difficulty);
|
||||
assert(glimit != block.gaslimit);
|
||||
assert(number != block.number);
|
||||
assert(tstamp != block.timestamp);
|
||||
assert(mdata.length != msg.data.length);
|
||||
assert(sender != msg.sender);
|
||||
assert(sig != msg.sig);
|
||||
assert(value != msg.value);
|
||||
assert(gprice != tx.gasprice);
|
||||
assert(origin != tx.origin);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 6328: (545-576): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (580-610): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (614-645): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (649-681): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (685-715): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (719-752): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (756-795): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (799-827): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (831-853): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (857-883): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (887-916): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (920-947): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (986-1017): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (1021-1051): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (1055-1086): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (1090-1122): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (1126-1156): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (1160-1193): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (1197-1236): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (1240-1268): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (1272-1294): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (1298-1324): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (1328-1357): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (1361-1388): CHC: Assertion violation happens here.
|
||||
@@ -16,7 +16,8 @@ contract C
|
||||
// erase knowledge about storage references.
|
||||
assert(c[0] == 42);
|
||||
assert(a[0] == 2);
|
||||
assert(b[0] == 1);
|
||||
// Removed because current Spacer seg faults in cex generation.
|
||||
//assert(b[0] == 1);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
|
||||
@@ -17,7 +17,8 @@ contract C
|
||||
// erase knowledge about memory references.
|
||||
assert(c[0] == 42);
|
||||
// Fails because d == a is possible.
|
||||
assert(d[0] == 42);
|
||||
// Removed because current Spacer seg faults in cex generation.
|
||||
//assert(d[0] == 42);
|
||||
// Fails because b == a and d == a are possible.
|
||||
assert(a[0] == 2);
|
||||
// b == a is possible, but does not fail because b
|
||||
@@ -26,5 +27,4 @@ contract C
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 6328: (431-449): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (504-521): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (572-589): CHC: Assertion violation happens here.
|
||||
|
||||
@@ -16,7 +16,8 @@ contract C
|
||||
// Should not fail since knowledge is erased only for mapping (uint => uint).
|
||||
assert(severalMaps8[0][0] == 42);
|
||||
// Should fail since map == severalMaps3d[0][0] is possible.
|
||||
assert(severalMaps3d[0][0][0] == 42);
|
||||
// Removed because current Spacer seg faults in cex generation.
|
||||
//assert(severalMaps3d[0][0][0] == 42);
|
||||
}
|
||||
function g(uint x) public {
|
||||
f(severalMaps[x]);
|
||||
@@ -24,4 +25,3 @@ contract C
|
||||
}
|
||||
// ----
|
||||
// Warning 6328: (421-452): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (635-671): CHC: Assertion violation happens here.
|
||||
|
||||
@@ -7,12 +7,12 @@ contract C
|
||||
require(a[0] == 2);
|
||||
b[0] = 1;
|
||||
// Should fail since b == c is possible.
|
||||
assert(c[0] == 42);
|
||||
// Removed because current Spacer seg faults in cex generation.
|
||||
//assert(c[0] == 42);
|
||||
// Should fail since b == a is possible.
|
||||
assert(a[0] == 2);
|
||||
assert(b[0] == 1);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 6328: (228-246): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (293-310): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (361-378): CHC: Assertion violation happens here.
|
||||
|
||||
@@ -16,7 +16,8 @@ contract C
|
||||
// Should not fail since knowledge is erased only for mapping (uint => uint).
|
||||
assert(severalMaps8[0][0] == 42);
|
||||
// Should fail since map == severalMaps3d[0][0] is possible.
|
||||
assert(severalMaps3d[0][0][0] == 42);
|
||||
// Removed because current Spacer seg faults in cex generation.
|
||||
//assert(severalMaps3d[0][0][0] == 42);
|
||||
}
|
||||
function g(uint x) public {
|
||||
f(severalMaps[x]);
|
||||
@@ -24,4 +25,3 @@ contract C
|
||||
}
|
||||
// ----
|
||||
// Warning 6328: (425-456): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (639-675): CHC: Assertion violation happens here.
|
||||
|
||||
@@ -16,7 +16,8 @@ contract C
|
||||
// Fails because map2 == a is possible.
|
||||
assert(a[0] == 42);
|
||||
// Fails because map2 == maps[0] is possible.
|
||||
assert(maps[0][0] == 42);
|
||||
// Removed because current Spacer seg faults in cex generation.
|
||||
//assert(maps[0][0] == 42);
|
||||
// Should not fail since knowledge is erased only for mapping (uint => uint).
|
||||
assert(maps8[0][0] == 42);
|
||||
assert(map2[0] == 1);
|
||||
@@ -32,4 +33,3 @@ contract C
|
||||
// ----
|
||||
// Warning 6328: (397-417): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (463-481): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (533-557): CHC: Assertion violation happens here.
|
||||
|
||||
+11
-9
@@ -14,19 +14,21 @@ contract C {
|
||||
}
|
||||
function f(S memory s2) public pure {
|
||||
S[] memory s1 = new S[](3);
|
||||
assert(s1.length == 3);
|
||||
// Removed because current Spacer seg faults in cex generation.
|
||||
//assert(s1.length == 3);
|
||||
s1[0].x = 2;
|
||||
assert(s1[0].x == s2.x);
|
||||
// Removed because current Spacer seg faults in cex generation.
|
||||
//assert(s1[0].x == s2.x);
|
||||
s1[1].t.y = 3;
|
||||
assert(s1[1].t.y == s2.t.y);
|
||||
// Removed because current Spacer seg faults in cex generation.
|
||||
//assert(s1[1].t.y == s2.t.y);
|
||||
s1[2].a[2] = 4;
|
||||
assert(s1[2].a[2] == s2.a[2]);
|
||||
// Removed because current Spacer seg faults in cex generation.
|
||||
//assert(s1[2].a[2] == s2.a[2]);
|
||||
s1[0].ts[3].y = 5;
|
||||
assert(s1[0].ts[3].y == s2.ts[3].y);
|
||||
// Removed because current Spacer seg faults in cex generation.
|
||||
//assert(s1[0].ts[3].y == s2.ts[3].y);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 6328: (283-306): CHC: Assertion violation happens here.
|
||||
// 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 5667: (183-194): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
||||
|
||||
@@ -9,8 +9,9 @@ contract C {
|
||||
S s2;
|
||||
function f(bool b) public {
|
||||
S storage s3 = b ? s1 : s2;
|
||||
assert(s3.x == s1.x);
|
||||
assert(s3.x == s2.x);
|
||||
// Disabled because Spacer 4.8.9 seg fauts.
|
||||
//assert(s3.x == s1.x);
|
||||
//assert(s3.x == s2.x);
|
||||
// This is safe.
|
||||
assert(s3.x == s1.x || s3.x == s2.x);
|
||||
// This fails as false positive because of lack of support to aliasing.
|
||||
@@ -25,6 +26,4 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 6328: (158-178): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (182-202): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (352-388): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (402-438): CHC: Assertion violation happens here.
|
||||
|
||||
+8
-8
@@ -15,20 +15,20 @@ contract C {
|
||||
function f(S memory s2) public pure {
|
||||
S memory s1;
|
||||
s1.x = 2;
|
||||
assert(s1.x == s2.x);
|
||||
// Removed because current Spacer seg faults in cex generation.
|
||||
//assert(s1.x == s2.x);
|
||||
s1.t.y = 3;
|
||||
assert(s1.t.y == s2.t.y);
|
||||
// Removed because current Spacer seg faults in cex generation.
|
||||
//assert(s1.t.y == s2.t.y);
|
||||
s1.a[2] = 4;
|
||||
assert(s1.a[2] == s2.a[2]);
|
||||
s1.ts[3].y = 5;
|
||||
assert(s1.ts[3].y == s2.ts[3].y);
|
||||
// Removed because current Spacer seg faults in cex generation.
|
||||
//assert(s1.ts[3].y == s2.ts[3].y);
|
||||
s1.ts[4].a[5] = 6;
|
||||
assert(s1.ts[4].a[5] == s2.ts[4].a[5]);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 6328: (239-259): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (277-301): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (320-346): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (368-400): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (425-463): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (456-482): CHC: Assertion violation happens here.
|
||||
// Warning 6328: (629-667): CHC: Assertion violation happens here.
|
||||
|
||||
@@ -8,11 +8,11 @@ contract C {
|
||||
S s1;
|
||||
S s2;
|
||||
function f() public view {
|
||||
assert(s1.m[0] == s2.m[0]);
|
||||
// Disabled because Spacer 4.8.9 seg faults.
|
||||
//assert(s1.m[0] == s2.m[0]);
|
||||
}
|
||||
function g(uint a, uint b) public {
|
||||
s1.m[a] = b;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 6328: (143-169): CHC: Assertion violation happens here.
|
||||
|
||||
@@ -126,268 +126,6 @@ do \
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(YulParser)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(recursion_depth)
|
||||
{
|
||||
string input;
|
||||
for (size_t i = 0; i < 20000; i++)
|
||||
input += "{";
|
||||
input += "let x:u256 := 0:u256";
|
||||
for (size_t i = 0; i < 20000; i++)
|
||||
input += "}";
|
||||
|
||||
CHECK_ERROR(input, ParserError, "recursion");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(multiple_assignment)
|
||||
{
|
||||
CHECK_ERROR("{ let x:u256 function f() -> a:u256, b:u256 {} 123:u256, x := f() }", ParserError, "Variable name must precede \",\" in multiple assignment.");
|
||||
CHECK_ERROR("{ let x:u256 function f() -> a:u256, b:u256 {} x, 123:u256 := f() }", ParserError, "Variable name must precede \":=\" in assignment.");
|
||||
|
||||
/// NOTE: Travis hiccups if not having a variable
|
||||
char const* text = R"(
|
||||
{
|
||||
function f(a:u256) -> r1:u256, r2:u256 {
|
||||
r1 := a
|
||||
r2 := 7:u256
|
||||
}
|
||||
let x:u256 := 9:u256
|
||||
let y:u256 := 2:u256
|
||||
x, y := f(x)
|
||||
}
|
||||
)";
|
||||
BOOST_CHECK(successParse(text));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(if_statement)
|
||||
{
|
||||
BOOST_CHECK(successParse("{ if true:bool {} }"));
|
||||
BOOST_CHECK(successParse("{ if false:bool { let x:u256 := 3:u256 } }"));
|
||||
BOOST_CHECK(successParse("{ function f() -> x:bool {} if f() { let b:bool := f() } }"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(break_outside_of_for_loop)
|
||||
{
|
||||
CHECK_ERROR_DIALECT(
|
||||
"{ let x if x { break } }",
|
||||
SyntaxError,
|
||||
"Keyword \"break\" needs to be inside a for-loop body.",
|
||||
EVMDialect::strictAssemblyForEVMObjects(EVMVersion::constantinople())
|
||||
);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(continue_outside_of_for_loop)
|
||||
{
|
||||
CHECK_ERROR_DIALECT(
|
||||
"{ let x if x { continue } }",
|
||||
SyntaxError,
|
||||
"Keyword \"continue\" needs to be inside a for-loop body.",
|
||||
EVMDialect::strictAssemblyForEVMObjects(EVMVersion::constantinople())
|
||||
);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(for_statement)
|
||||
{
|
||||
auto const& dialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion::constantinople());
|
||||
BOOST_CHECK(successParse("{ for {let i := 0} iszero(eq(i, 10)) {i := add(i, 1)} {} }", dialect));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(for_statement_break)
|
||||
{
|
||||
auto const& dialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion::constantinople());
|
||||
BOOST_CHECK(successParse("{ for {let i := 0} iszero(eq(i, 10)) {i := add(i, 1)} {break} }", dialect));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(for_statement_break_init)
|
||||
{
|
||||
auto const& dialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion::constantinople());
|
||||
CHECK_ERROR_DIALECT(
|
||||
"{ for {let i := 0 break} iszero(eq(i, 10)) {i := add(i, 1)} {} }",
|
||||
SyntaxError,
|
||||
"Keyword \"break\" in for-loop init block is not allowed.",
|
||||
dialect
|
||||
);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(for_statement_break_post)
|
||||
{
|
||||
auto const& dialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion::constantinople());
|
||||
CHECK_ERROR_DIALECT(
|
||||
"{ for {let i := 0} iszero(eq(i, 10)) {i := add(i, 1) break} {} }",
|
||||
SyntaxError,
|
||||
"Keyword \"break\" in for-loop post block is not allowed.",
|
||||
dialect
|
||||
);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(for_statement_nested_break)
|
||||
{
|
||||
auto const& dialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion::constantinople());
|
||||
CHECK_ERROR_DIALECT(
|
||||
"{ for {let i := 0} iszero(eq(i, 10)) {} { function f() { break } } }",
|
||||
SyntaxError,
|
||||
"Keyword \"break\" needs to be inside a for-loop body.",
|
||||
dialect
|
||||
);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(for_statement_continue)
|
||||
{
|
||||
auto const& dialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion::constantinople());
|
||||
BOOST_CHECK(successParse("{ for {let i := 0} iszero(eq(i, 10)) {i := add(i, 1)} {continue} }", dialect));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(for_statement_continue_fail_init)
|
||||
{
|
||||
auto const& dialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion::constantinople());
|
||||
CHECK_ERROR_DIALECT(
|
||||
"{ for {let i := 0 continue} iszero(eq(i, 10)) {i := add(i, 1)} {} }",
|
||||
SyntaxError,
|
||||
"Keyword \"continue\" in for-loop init block is not allowed.",
|
||||
dialect
|
||||
);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(for_statement_continue_fail_post)
|
||||
{
|
||||
auto const& dialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion::constantinople());
|
||||
CHECK_ERROR_DIALECT(
|
||||
"{ for {let i := 0} iszero(eq(i, 10)) {i := add(i, 1) continue} {} }",
|
||||
SyntaxError,
|
||||
"Keyword \"continue\" in for-loop post block is not allowed.",
|
||||
dialect
|
||||
);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(for_statement_nested_continue)
|
||||
{
|
||||
auto const& dialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion::constantinople());
|
||||
CHECK_ERROR_DIALECT(
|
||||
"{ for {let i := 0} iszero(eq(i, 10)) {} { function f() { continue } } }",
|
||||
SyntaxError,
|
||||
"Keyword \"continue\" needs to be inside a for-loop body.",
|
||||
dialect
|
||||
);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(for_statement_continue_nested_init_in_body)
|
||||
{
|
||||
auto const& dialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion::constantinople());
|
||||
CHECK_ERROR_DIALECT(
|
||||
"{ for {} 1 {} {let x for { continue } x {} {}} }",
|
||||
SyntaxError,
|
||||
"Keyword \"continue\" in for-loop init block is not allowed.",
|
||||
dialect
|
||||
);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(for_statement_continue_nested_body_in_init)
|
||||
{
|
||||
auto const& dialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion{});
|
||||
BOOST_CHECK(successParse("{ for {let x for {} x {} { continue }} 1 {} {} }", dialect));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(for_statement_break_nested_body_in_init)
|
||||
{
|
||||
auto const& dialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion{});
|
||||
BOOST_CHECK(successParse("{ for {let x for {} x {} { break }} 1 {} {} }", dialect));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(for_statement_continue_nested_body_in_post)
|
||||
{
|
||||
auto const& dialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion{});
|
||||
BOOST_CHECK(successParse("{ for {} 1 {let x for {} x {} { continue }} {} }", dialect));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(for_statement_break_nested_body_in_post)
|
||||
{
|
||||
auto const& dialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion{});
|
||||
BOOST_CHECK(successParse("{ for {} 1 {let x for {} x {} { break }} {} }", dialect));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(function_defined_in_init_block)
|
||||
{
|
||||
auto const& dialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion{});
|
||||
BOOST_CHECK(successParse("{ for { } 1 { function f() {} } {} }", dialect));
|
||||
BOOST_CHECK(successParse("{ for { } 1 {} { function f() {} } }", dialect));
|
||||
CHECK_ERROR_DIALECT(
|
||||
"{ for { function f() {} } 1 {} {} }",
|
||||
SyntaxError,
|
||||
"Functions cannot be defined inside a for-loop init block.",
|
||||
dialect
|
||||
);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(function_defined_in_init_nested)
|
||||
{
|
||||
auto const& dialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion{});
|
||||
BOOST_CHECK(successParse(
|
||||
"{ for {"
|
||||
"for { } 1 { function f() {} } {}"
|
||||
"} 1 {} {} }", dialect));
|
||||
CHECK_ERROR_DIALECT(
|
||||
"{ for { for {function foo() {}} 1 {} {} } 1 {} {} }",
|
||||
SyntaxError,
|
||||
"Functions cannot be defined inside a for-loop init block.",
|
||||
dialect
|
||||
);
|
||||
CHECK_ERROR_DIALECT(
|
||||
"{ for {} 1 {for {function foo() {}} 1 {} {} } {} }",
|
||||
SyntaxError,
|
||||
"Functions cannot be defined inside a for-loop init block.",
|
||||
dialect
|
||||
);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(if_statement_invalid)
|
||||
{
|
||||
CHECK_ERROR("{ if let x:u256 {} }", ParserError, "Literal or identifier expected.");
|
||||
CHECK_ERROR("{ if true:bool let x:u256 := 3:u256 }", ParserError, "Expected '{' but got reserved keyword 'let'");
|
||||
CHECK_ERROR("{ if 42:u256 { } }", TypeError, "Expected a value of boolean type");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(switch_duplicate_case)
|
||||
{
|
||||
CHECK_ERROR("{ switch 0:u256 case 0:u256 {} case 0x0:u256 {} }", DeclarationError, "Duplicate case defined.");
|
||||
BOOST_CHECK(successParse("{ switch 0:u256 case 42:u256 {} case 0x42:u256 {} }"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(switch_duplicate_case_different_literal)
|
||||
{
|
||||
CHECK_ERROR("{ switch 0:u256 case 0:u256 {} case \"\":u256 {} }", DeclarationError, "Duplicate case defined.");
|
||||
BOOST_CHECK(successParse("{ switch 1:u256 case \"1\":u256 {} case \"2\":u256 {} }"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(switch_case_string_literal_too_long)
|
||||
{
|
||||
BOOST_CHECK(successParse("{let x:u256 switch x case \"01234567890123456789012345678901\":u256 {}}"));
|
||||
CHECK_ERROR("{let x:u256 switch x case \"012345678901234567890123456789012\":u256 {}}", TypeError, "String literal too long (33 > 32)");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(function_shadowing_outside_vars)
|
||||
{
|
||||
CHECK_ERROR("{ let x:u256 function f() -> x:u256 {} }", DeclarationError, "already taken in this scope");
|
||||
BOOST_CHECK(successParse("{ { let x:u256 } function f() -> x:u256 {} }"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(builtins_parser)
|
||||
{
|
||||
struct SimpleDialect: public Dialect
|
||||
{
|
||||
BuiltinFunction const* builtin(YulString _name) const override
|
||||
{
|
||||
return _name == "builtin"_yulstring ? &f : nullptr;
|
||||
}
|
||||
BuiltinFunction f;
|
||||
};
|
||||
|
||||
SimpleDialect dialect;
|
||||
CHECK_ERROR_DIALECT("{ let builtin := 6 }", ParserError, "Cannot use builtin function name \"builtin\" as identifier name.", dialect);
|
||||
CHECK_ERROR_DIALECT("{ function builtin() {} }", ParserError, "Cannot use builtin function name \"builtin\" as identifier name.", dialect);
|
||||
CHECK_ERROR_DIALECT("{ function f(x) { f(builtin) } }", ParserError, "Expected '(' but got ')'", dialect);
|
||||
CHECK_ERROR_DIALECT("{ function f(builtin) {}", ParserError, "Cannot use builtin function name \"builtin\" as identifier name.", dialect);
|
||||
CHECK_ERROR_DIALECT("{ function f() -> builtin {}", ParserError, "Cannot use builtin function name \"builtin\" as identifier name.", dialect);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(builtins_analysis)
|
||||
{
|
||||
struct SimpleDialect: public Dialect
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
let x:bool
|
||||
if x { break }
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
||||
// SyntaxError 2592: (22-27): Keyword "break" needs to be inside a for-loop body.
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
let add := 6
|
||||
}
|
||||
// ----
|
||||
// ParserError 5568: (7-10): Cannot use builtin function name "add" as identifier name.
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
function add() {}
|
||||
}
|
||||
// ----
|
||||
// ParserError 5568: (12-15): Cannot use builtin function name "add" as identifier name.
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
function f(x) { f(add) }
|
||||
}
|
||||
// ----
|
||||
// ParserError 2314: (24-25): Expected '(' but got ')'
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
function f(add) {}
|
||||
}
|
||||
// ----
|
||||
// ParserError 5568: (14-17): Cannot use builtin function name "add" as identifier name.
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
function f() -> add {}
|
||||
}
|
||||
// ----
|
||||
// ParserError 5568: (19-22): Cannot use builtin function name "add" as identifier name.
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
let x:bool
|
||||
if x { continue }
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
||||
// SyntaxError 2592: (22-30): Keyword "continue" needs to be inside a for-loop body.
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
let x:bool
|
||||
for {let i := 0} x {i := add(i, 1)} {}
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
let x:bool
|
||||
for {let i := 0} x {i := add(i, 1)}
|
||||
{
|
||||
break
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
let x:bool
|
||||
for {let i := 0 break} x {i := add(i, 1)} {}
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
||||
// SyntaxError 9615: (31-36): Keyword "break" in for-loop init block is not allowed.
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
for {let x:bool for {} x {} { break }} 1:bool {}
|
||||
{}
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
for {} 1:bool {let x:bool for {} x {} { break }}
|
||||
{}
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
let x:bool
|
||||
for {let i := 0 } x {i := add(i, 1) break} {}
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
||||
// SyntaxError 2461: (51-56): Keyword "break" in for-loop post block is not allowed.
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
let x:bool
|
||||
for {let i := 0} x {i := add(i, 1)}
|
||||
{
|
||||
continue
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
let x:bool
|
||||
for {let i := 0 continue} x {i := add(i, 1)}
|
||||
{
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
||||
// SyntaxError 9615: (31-39): Keyword "continue" in for-loop init block is not allowed.
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
let x:bool
|
||||
for {let i := 0} x {i := add(i, 1) continue} {}
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
||||
// SyntaxError 2461: (50-58): Keyword "continue" in for-loop post block is not allowed.
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
for {let x:bool for {} x {} { continue }} 1:bool {}
|
||||
{
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
for {} 1:bool {let x:bool for {} x {} { continue }}
|
||||
{}
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
for {} 1 {}
|
||||
{
|
||||
let x:bool
|
||||
for { continue } x {} {}
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
||||
// SyntaxError 9615: (39-47): Keyword "continue" in for-loop init block is not allowed.
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user