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

This commit is contained in:
chriseth
2020-11-03 14:05:14 +01:00
206 changed files with 1420 additions and 862 deletions
@@ -20,5 +20,7 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f() -> 0x20, 0x8, 0x40, 0x3, 0x9, 0xa, 0xb
@@ -0,0 +1,16 @@
contract C {
function f(uint a, bytes memory b, uint c)
public pure returns (uint, uint, byte, uint) {
return (a, b.length, b[3], c);
}
function f_external(uint a, bytes calldata b, uint c)
external pure returns (uint, uint, byte, uint) {
return (a, b.length, b[3], c);
}
}
// ====
// compileViaYul: also
// ----
// f(uint256,bytes,uint256): 6, 0x60, 9, 7, "abcdefg" -> 6, 7, "d", 9
// f_external(uint256,bytes,uint256): 6, 0x60, 9, 7, "abcdefg" -> 6, 7, "d", 9
@@ -0,0 +1,10 @@
contract C {
function f(uint a, uint16[] memory b, uint c)
public pure returns (uint, uint, uint) {
return (b.length, b[a], c);
}
}
// ====
// compileViaYul: also
// ----
// f(uint256,uint16[],uint256): 6, 0x60, 9, 7, 11, 12, 13, 14, 15, 16, 17 -> 7, 17, 9
@@ -0,0 +1,13 @@
contract C {
enum E { A, B }
function f(E e) public pure returns (uint x) {
assembly { x := e }
}
}
// ====
// ABIEncoderV1Only: true
// ----
// f(uint8): 0 -> 0
// f(uint8): 1 -> 1
// f(uint8): 2 -> 2
// f(uint8): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -> 0xff
@@ -0,0 +1,18 @@
pragma experimental ABIEncoderV2;
contract C {
function f(uint a, bytes memory b, uint c)
public pure returns (uint, uint, byte, uint) {
return (a, b.length, b[3], c);
}
function f_external(uint a, bytes calldata b, uint c)
external pure returns (uint, uint, byte, uint) {
return (a, b.length, b[3], c);
}
}
// ====
// compileViaYul: also
// ----
// f(uint256,bytes,uint256): 6, 0x60, 9, 7, "abcdefg" -> 6, 7, "d", 9
// f_external(uint256,bytes,uint256): 6, 0x60, 9, 7, "abcdefg" -> 6, 7, "d", 9
@@ -41,6 +41,7 @@ contract C {
}
}
// ====
// compileViaYul: also
// EVMVersion: >homestead
// ----
// g() -> 32, 132, hex"15cfcc01", 32, 32, 1, 42, hex"00000000000000000000000000000000000000000000000000000000"
@@ -0,0 +1,12 @@
pragma experimental ABIEncoderV2;
contract C {
function f(uint a, uint16[] memory b, uint c)
public pure returns (uint, uint, uint) {
return (b.length, b[a], c);
}
}
// ====
// compileViaYul: also
// ----
// f(uint256,uint16[],uint256): 6, 0x60, 9, 7, 11, 12, 13, 14, 15, 16, 17 -> 7, 17, 9
@@ -0,0 +1,32 @@
pragma experimental ABIEncoderV2;
contract C {
function f(uint a, uint16[][] memory b, uint[2][][3] memory c, uint d)
public pure returns (uint, uint, uint, uint, uint, uint, uint) {
return (a, b.length, b[1].length, b[1][1], c[1].length, c[1][1][1], d);
}
function test() public view returns (uint, uint, uint, uint, uint, uint, uint) {
uint16[][] memory b = new uint16[][](3);
b[0] = new uint16[](2);
b[0][0] = 0x55;
b[0][1] = 0x56;
b[1] = new uint16[](4);
b[1][0] = 0x65;
b[1][1] = 0x66;
b[1][2] = 0x67;
b[1][3] = 0x68;
uint[2][][3] memory c;
c[0] = new uint[2][](1);
c[0][0][1] = 0x75;
c[1] = new uint[2][](5);
c[1][1][1] = 0x85;
return this.f(12, b, c, 13);
}
}
// ====
// compileViaYul: also
// ----
// test() -> 12, 3, 4, 0x66, 5, 0x85, 13
// f(uint256,uint16[][],uint256[2][][3],uint256): 12, 0x80, 0x220, 13, 3, 0x60, 0xC0, 0x160, 2, 85, 86, 4, 101, 102, 103, 104, 0, 0x60, 0xC0, 0x220, 1, 0, 117, 5, 0, 0, 0, 133, 0, 0, 0, 0, 0, 0, 0 -> 12, 3, 4, 0x66, 5, 0x85, 13
@@ -0,0 +1,15 @@
pragma experimental ABIEncoderV2;
contract C {
enum E { A, B }
function f(E e) public pure returns (uint x) {
assembly { x := e }
}
}
// ====
// compileViaYul: also
// ----
// f(uint8): 0 -> 0
// f(uint8): 1 -> 1
// f(uint8): 2 -> FAILURE
// f(uint8): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -> FAILURE
@@ -7,5 +7,7 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f(bytes): 0x20, 0x80, 0x21, 0x40, 0x7, "abcdefg" -> 0x21, 0x40, 0x7, "abcdefg"
@@ -14,5 +14,7 @@ contract c {
uint8(data[97]) == 97;
}
}
// ====
// compileViaYul: also
// ----
// test1() -> true
@@ -10,6 +10,8 @@ contract c {
bytes data;
}
// ====
// compileViaYul: also
// ----
// getLength() -> 0
// set(): 1, 2 -> true
@@ -6,5 +6,7 @@ contract C {
return s[0];
}
}
// ====
// compileViaYul: also
// ----
// f() -> "a"
@@ -5,5 +5,7 @@ contract C {
return s[0];
}
}
// ====
// compileViaYul: also
// ----
// f(bytes): 0x20, 0x08, "abcdefgh" -> "a"
@@ -0,0 +1,42 @@
pragma experimental ABIEncoderV2;
struct S {
uint16 x;
bytes a;
uint16 y;
bytes b;
}
contract C {
uint padding;
S data;
function f() public returns (bytes memory, bytes memory) {
S memory x;
x.x = 7;
x.b = "1234567890123456789012345678901 1234567890123456789012345678901 123456789";
x.a = "abcdef";
x.y = 9;
data = x;
return (data.a, data.b);
}
function g() public returns (bytes memory, bytes memory) {
S memory x;
x.x = 7;
x.b = "12345678923456789";
x.a = "1234567890123456789012345678901 1234567890123456789012345678901 123456789";
x.y = 9;
data = x;
return (data.a, data.b);
}
function h() public returns (bytes memory, bytes memory) {
S memory x;
data = x;
return (data.a, data.b);
}
}
// ====
// compileViaYul: also
// ----
// f() -> 0x40, 0x80, 6, 0x6162636465660000000000000000000000000000000000000000000000000000, 0x49, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738390000000000000000000000000000000000000000000000
// g() -> 0x40, 0xc0, 0x49, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738390000000000000000000000000000000000000000000000, 0x11, 0x3132333435363738393233343536373839000000000000000000000000000000
// h() -> 0x40, 0x60, 0x00, 0x00
// storage: empty
@@ -0,0 +1,50 @@
function dataslot() pure returns (bytes32) {
return keccak256(abi.encode(1));
}
function readDataSlot(uint offset) view returns (bytes32 r) {
bytes32 s = dataslot();
assembly { r := sload(add(s, offset)) }
}
function readDataSlot() view returns (bytes32) {
return readDataSlot(0);
}
function readHead() view returns (bytes32 r) {
assembly { r := sload(1) }
}
contract C {
uint padding;
bytes data;
function f() public returns (uint) {
bytes32 zero;
if (!(readDataSlot() == zero)) return 1;
data = "abc";
if (!(readDataSlot() == zero)) return 2;
data = "1234567890123456789012345678901234567890123456789012345678901234567890";
if (!(readDataSlot() != zero)) return 3;
if (!(readDataSlot(1) != zero)) return 4;
if (!(readDataSlot(2) != zero)) return 5;
if (!(readDataSlot(3) == zero)) return 6;
if (!(readDataSlot(4) == zero)) return 7;
data = "abc";
if (!(readDataSlot() == zero)) return 8;
if (!(readDataSlot(1) == zero)) return 9;
if (!(readDataSlot(2) == zero)) return 10;
if (!(readDataSlot(3) == zero)) return 11;
data = "1234567890123456789012345678901234567890123456789012345678901234567890";
data = "123456789012345678901234567890123456";
if (!(readDataSlot() != zero)) return 12;
if (!(readDataSlot(1) != zero)) return 13;
if (!(readDataSlot(2) == zero)) return 14;
if (!(readDataSlot(3) == zero)) return 15;
return 0xff;
}
}
// ====
// compileViaYul: also
// ----
// f() -> 0xff
@@ -17,6 +17,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// one() -> 3
// two() -> FAILURE, hex"4e487b71", 0x51
@@ -5,6 +5,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f(uint256): 0 -> 0x20, 0x4, "This"
// f(uint256): 1 -> 0x20, 0x2, "is"
@@ -13,5 +13,7 @@ contract C {
return this.h(a);
}
}
// ====
// compileViaYul: also
// ----
// g() -> 0x0700000000000000000000000000000000000000000000000000000000000000
@@ -16,6 +16,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// use(uint256): 3 -> 6
// result_in_constructor() -> 4
@@ -0,0 +1,25 @@
contract C {
uint16 public result_in_constructor;
function(uint16) returns (uint16) internal x;
uint16 public other = 0x1fff;
constructor() {
x = doubleInv;
result_in_constructor = use(2);
}
function doubleInv(uint16 _arg) public returns (uint16 _ret) {
_ret = ~(_arg * 2);
}
function use(uint16 _arg) public returns (uint16) {
return x(_arg);
}
}
// ====
// compileViaYul: also
// ----
// use(uint16): 3 -> 0xfff9
// result_in_constructor() -> 0xfffb
// other() -> 0x1fff
@@ -14,5 +14,7 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// t() -> 7
@@ -17,5 +17,7 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// t() -> 7
@@ -0,0 +1,13 @@
contract test {
function f() public returns(uint ret) {
ret = 1;
for (;;) {
ret += 1;
if (ret >= 10) break;
}
}
}
// ====
// compileViaYul: also
// ----
// f() -> 10
@@ -0,0 +1,22 @@
contract collatz {
function run(uint x) public returns(uint y) {
while ((y = x) > 1) {
if (x % 2 == 0) x = evenStep(x);
else x = oddStep(x);
}
}
function evenStep(uint x) public returns(uint y) {
return x / 2;
}
function oddStep(uint x) public returns(uint y) {
return 3 * x + 1;
}
}
// ====
// compileViaYul: also
// ----
// run(uint256): 0 -> 0
// run(uint256): 1 -> 1
// run(uint256): 2 -> 1
// run(uint256): 8 -> 1
// run(uint256): 127 -> 1
@@ -16,5 +16,7 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// t() -> FAILURE, hex"4e487b71", 0x51
@@ -20,6 +20,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// set() -> 7
// ca() -> 7
@@ -6,5 +6,7 @@ contract C {
return [this.f, this.g][0]{value: 1}();
}
}
// ====
// compileViaYul: also
// ----
// h(), 1 ether -> 1
@@ -25,6 +25,8 @@ contract Flow {
}
}
// ====
// compileViaYul: also
// ----
// success() -> false
// f() -> 7
@@ -11,5 +11,7 @@ contract C {
return x + 1;
}
}
// ====
// compileViaYul: also
// ----
// f(uint256): 7 -> 8
@@ -14,5 +14,7 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// test() -> true
@@ -0,0 +1,34 @@
struct S {
uint16 a;
function() returns (uint) x;
uint16 b;
}
contract Flow {
S[2] t;
function X() internal pure returns (uint) {
return 1;
}
function Y() internal pure returns (uint) {
return 2;
}
constructor() {
t[0].a = 0xff07;
t[0].b = 0xff07;
t[1].x = Y;
t[1].a = 0xff07;
t[1].b = 0xff07;
t[0].x = X;
}
function f() public returns (uint, uint) {
return (t[0].x(), t[1].x());
}
}
// ====
// compileViaYul: also
// ----
// f() -> 1, 2
@@ -7,5 +7,7 @@ contract Test {
}
}
// ====
// compileViaYul: also
// ----
// f() -> FAILURE, hex"4e487b71", 0x51
@@ -0,0 +1,11 @@
contract test {
function run(uint x1, uint x2, uint x3) public returns(uint y) {
uint8 a = 0x1; uint8 b = 0x10; uint16 c = 0x100;
y = a + b + c + x1 + x2 + x3;
y += b + x2;
}
}
// ====
// compileViaYul: also
// ----
// run(uint256,uint256,uint256): 0x1000, 0x10000, 0x100000 -> 0x121121
@@ -0,0 +1,9 @@
contract test {
function run() public returns(int256 y) {
return -int32(10) * -int64(20);
}
}
// ====
// compileViaYul: also
// ----
// run() -> 200
@@ -29,6 +29,8 @@ contract Homer is ERC165, Simpson {
}
}
// ====
// compileViaYul: also
// ----
// supportsInterface(bytes4): left(0x01ffc9a0) -> false
// supportsInterface(bytes4): left(0x01ffc9a7) -> true
@@ -40,6 +40,8 @@ contract Lisa is ERC165MappingImplementation, Simpson {
}
}
// ====
// compileViaYul: also
// ----
// supportsInterface(bytes4): left(0x01ffc9a0) -> false
// supportsInterface(bytes4): left(0x01ffc9a7) -> true
@@ -14,6 +14,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// g() -> 2
// h() -> FAILURE, hex"4e487b71", 0x51
@@ -0,0 +1,22 @@
contract test {
uint value1;
uint value2;
function f(uint x, uint y) public returns (uint w) {
uint value3 = y;
value1 += x;
value3 *= x;
value2 *= value3 + value1;
return value2 += 7;
}
}
// ====
// compileViaYul: also
// ----
// f(uint256,uint256): 0, 6 -> 7
// f(uint256,uint256): 1, 3 -> 0x23
// f(uint256,uint256): 2, 25 -> 0x0746
// f(uint256,uint256): 3, 69 -> 396613
// f(uint256,uint256): 4, 84 -> 137228105
// f(uint256,uint256): 5, 2 -> 0xcc7c5e28
// f(uint256,uint256): 6, 51 -> 1121839760671
// f(uint256,uint256): 7, 48 -> 408349672884251
@@ -17,6 +17,7 @@ contract C {
}
}
// ====
// compileViaYul: also
// EVMVersion: >=byzantium
// ----
// test_store_ok() -> 1
@@ -18,6 +18,8 @@ contract D {
return (stateBool, stateDecimal, stateBytes);
}
}
// ====
// compileViaYul: also
// ----
// stateBool() -> true
// stateBool() -> right(true)
@@ -32,6 +32,8 @@ contract C {
return (["any", "any"], ["any", "any", "any"]);
}
}
// ====
// compileViaYul: also
// ----
// r() -> true, false, true
// s() -> 123, 456, 789
@@ -41,4 +43,3 @@ contract C {
// w2() -> 0x20, 0x40, 0x80, 3, "any", 3, "any"
// w3() -> 0x20, 0x60, 0xa0, 0xe0, 3, "any", 3, "any", 3, "any"
// x() -> 0x40, 0x0100, 0x40, 0x80, 3, "any", 3, "any", 0x60, 0xa0, 0xe0, 3, "any", 3, "any", 3, "any"
@@ -2,6 +2,8 @@ contract Test {
bytes x;
function set(bytes memory _a) public { x = _a; }
}
// ====
// compileViaYul: also
// ----
// set(bytes): 0x20, 3, "abc"
// storage: nonempty
@@ -0,0 +1,46 @@
contract Ballot {
mapping(address => bool) canVote;
mapping(address => uint) voteCount;
mapping(address => bool) voted;
function getVoteCount(address addr) public returns (uint retVoteCount) {
return voteCount[addr];
}
function grantVoteRight(address addr) public {
canVote[addr] = true;
}
function vote(address voter, address vote) public returns (bool success) {
if (!canVote[voter] || voted[voter]) return false;
voted[voter] = true;
voteCount[vote] = voteCount[vote] + 1;
return true;
}
}
// ====
// compileViaYul: also
// ----
// getVoteCount(address): 0 -> 0
// getVoteCount(address): 1 -> 0
// getVoteCount(address): 2 -> 0
// vote(address,address): 0, 2 -> false
// getVoteCount(address): 0 -> 0
// getVoteCount(address): 1 -> 0
// getVoteCount(address): 2 -> 0
// grantVoteRight(address): 0 ->
// grantVoteRight(address): 1 ->
// vote(address,address): 0, 2 -> true
// getVoteCount(address): 0 -> 0
// getVoteCount(address): 1 -> 0
// getVoteCount(address): 2 -> 1
// vote(address,address): 0, 1 -> false
// getVoteCount(address): 0 -> 0
// getVoteCount(address): 1 -> 0
// getVoteCount(address): 2 -> 1
// vote(address,address): 2, 1 -> false
// getVoteCount(address): 0 -> 0
// getVoteCount(address): 1 -> 0
// getVoteCount(address): 2 -> 1
// grantVoteRight(address): 2 ->
// vote(address,address): 2, 1 -> true
// getVoteCount(address): 0 -> 0
// getVoteCount(address): 1 -> 1
// getVoteCount(address): 2 -> 1
@@ -8,5 +8,7 @@ contract Test {
assert(val[0].vals.length == 42);
}
}
// -----
// ====
// compileViaYul: also
// ----
// func() ->
@@ -35,5 +35,7 @@ contract InvalidTest {
x++;
}
}
// ====
// compileViaYul: also
// ----
// run() -> FAILURE, hex"4e487b71", 0x51
@@ -14,6 +14,8 @@ contract InvalidTest {
storedFn();
}
}
// ====
// compileViaYul: also
// ----
// f() -> FAILURE, hex"4e487b71", 0x51
// f() -> FAILURE, hex"4e487b71", 0x51
@@ -32,5 +32,7 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f(bytes): 0x20, 0x5, "abcde" -> 0
@@ -19,5 +19,7 @@ contract C {
return (a, b);
}
}
// ====
// compileViaYul: also
// ----
// g() -> 5, 6
@@ -8,6 +8,8 @@ contract C {
bytes savedData;
}
// ====
// compileViaYul: also
// ----
// save() -> 24 # empty copy loop #
// save(): "abcdefg" -> 24