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

This commit is contained in:
chriseth
2020-10-08 20:18:04 +02:00
91 changed files with 924 additions and 171 deletions
@@ -16,5 +16,7 @@ contract c {
}
}
// ====
// compileViaYul: also
// ----
// test() -> 0x20, 0x8, -1, -1, 8, -16, -2, 6, 8, -1
@@ -6,5 +6,7 @@ contract C {
return (b[0], b.length);
}
}
// ====
// compileViaYul: also
// ----
// f() -> 1, 3
@@ -8,5 +8,7 @@ contract c {
}
}
// ====
// compileViaYul: also
// ----
// test() -> 0x20, 29, 0x0303030303030303030303030303030303030303030303030303030303000000
@@ -8,5 +8,7 @@ contract c {
}
}
// ====
// compileViaYul: also
// ----
// test() -> 0x20, 33, 0x303030303030303030303030303030303030303030303030303030303030303, 0x0300000000000000000000000000000000000000000000000000000000000000
@@ -0,0 +1,21 @@
contract C {
uint72[5][] a;
function f() public returns (uint72, uint72, uint72, uint72, uint72, uint72, uint72) {
for (uint i = 0; i < 4; i++)
a.push();
a[0][0] = 1;
a[0][3] = 2;
a[1][1] = 3;
a[1][4] = 4;
a[2][0] = 5;
a[3][2] = 6;
a[3][3] = 7;
uint72[5][] memory m = a;
return (m[0][0], m[0][3], m[1][1], m[1][4], m[2][0], m[3][2], m[3][3]);
}
}
// ====
// compileViaYul: also
// ----
// f() -> 1, 2, 3, 4, 5, 6, 7
@@ -0,0 +1,13 @@
pragma experimental ABIEncoderV2;
contract C {
bytes[] a;
function f() public returns (bytes[] memory) {
a.push("abc");
a.push("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVXYZ");
bytes[] memory m = a;
return m;
}
}
// ----
// f() -> 0x20, 0x02, 0x40, 0x80, 3, 0x6162630000000000000000000000000000000000000000000000000000000000, 0x99, 44048183304486788312148433451363384677562265908331949128489393215789685032262, 32241931068525137014058842823026578386641954854143559838526554899205067598957, 49951309422467613961193228765530489307475214998374779756599339590522149884499, 0x54555658595a6162636465666768696a6b6c6d6e6f707172737475767778797a, 0x4142434445464748494a4b4c4d4e4f5051525354555658595a00000000000000
@@ -0,0 +1,22 @@
contract C {
uint72[5][] a;
function f() public returns (uint72, uint72, uint72, uint72, uint72, uint72, uint72) {
for (uint i = 0; i < 4; i++)
a.push();
a[0][0] = 1;
a[0][3] = 2;
a[1][1] = 3;
a[1][4] = 4;
a[2][0] = 5;
a[3][2] = 6;
a[3][3] = 7;
uint72[5][] storage a_ = a;
uint72[5][] memory m = a_;
return (m[0][0], m[0][3], m[1][1], m[1][4], m[2][0], m[3][2], m[3][3]);
}
}
// ====
// compileViaYul: also
// ----
// f() -> 1, 2, 3, 4, 5, 6, 7
@@ -0,0 +1,26 @@
contract C {
struct T { uint8 x; uint8 y; uint[] z; }
T[3][] a;
function f() public returns (uint8, uint8, uint, uint, uint, uint8, uint8, uint, uint, uint) {
a.push();
a.push();
a[0][1].x = 11;
a[0][1].y = 12;
a[0][1].z.push(1);
a[0][1].z.push(2);
a[0][1].z.push(3);
a[1][2].x = 21;
a[1][2].y = 22;
a[1][2].z.push(4);
a[1][2].z.push(5);
a[1][2].z.push(6);
T[3][] memory m = a;
return (
m[0][1].x, m[0][1].y, m[0][1].z[0], m[0][1].z[1], m[0][1].z[2],
m[1][2].x, m[1][2].y, m[1][2].z[0], m[1][2].z[1], m[1][2].z[2]
);
}
}
// ----
// f() -> 11, 0x0c, 1, 2, 3, 0x15, 22, 4, 5, 6
@@ -0,0 +1,15 @@
contract C {
uint8[33] a;
function f() public returns (uint8, uint8, uint8) {
a[0] = 2;
a[16] = 3;
a[32] = 4;
uint8[33] memory m = a;
return (m[0], m[16], m[32]);
}
}
// ====
// compileViaYul: also
// ----
// f() -> 2, 3, 4
@@ -0,0 +1,17 @@
contract C {
uint8[] a;
function f() public returns (uint8, uint8, uint8) {
for (uint i = 0; i < 33; i++)
a.push(7);
a[0] = 2;
a[16] = 3;
a[32] = 4;
uint8[] memory m = a;
return (m[0], m[16], m[32]);
}
}
// ====
// compileViaYul: also
// ----
// f() -> 2, 3, 4
@@ -16,5 +16,7 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f() -> true # This code interprets x as an array length and thus will go out of gas. neither of the two should throw due to out-of-bounds access #
@@ -15,5 +15,7 @@ contract Test {
return set(data)[1];
}
}
// ====
// compileViaYul: also
// ----
// f() -> 0x20, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x07
@@ -31,6 +31,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// l() -> 0
// f(uint256): 42 ->
@@ -8,5 +8,7 @@ contract c {
return keccak256(abi.encodePacked("b", keccak256(data), "a"));
}
}
// ====
// compileViaYul: also
// ----
// foo() -> 0xb338eefce206f9f57b83aa738deecd5326dc4b72dd81ee6a7c621a6facb7acdc
@@ -9,5 +9,7 @@ contract c {
}
}
// ====
// compileViaYul: also
// ----
// foo() -> true
@@ -0,0 +1,9 @@
address constant e = 0x1212121212121212121212121000002134593163;
contract C {
function f() public returns (address z) {
assembly { z := e }
}
}
// ----
// f() -> 0x1212121212121212121212121000002134593163
@@ -0,0 +1,33 @@
bytes constant a = "\x03\x01\x02";
bytes constant b = hex"030102";
string constant c = "hello";
uint256 constant x = 56;
enum ActionChoices {GoLeft, GoRight, GoStraight, Sit}
ActionChoices constant choices = ActionChoices.GoRight;
bytes32 constant st = "abc\x00\xff__";
contract C {
function f() public returns (bytes memory) {
return a;
}
function g() public returns (bytes memory) {
return b;
}
function h() public returns (bytes memory) {
return bytes(c);
}
function i() public returns (uint, ActionChoices, bytes32) {
return (x, choices, st);
}
}
// ====
// compileViaYul: also
// ----
// f() -> 0x20, 3, "\x03\x01\x02"
// g() -> 0x20, 3, "\x03\x01\x02"
// h() -> 0x20, 5, "hello"
// i() -> 0x38, 1, 0x61626300ff5f5f00000000000000000000000000000000000000000000000000
@@ -0,0 +1,41 @@
==== Source: s1.sol ====
bytes constant a = b;
bytes constant b = hex"030102";
function fre() pure returns (bytes memory) {
return a;
}
==== Source: s2.sol ====
import "s1.sol";
uint256 constant c = uint8(a[0]) + 2;
contract C {
function f() public returns (bytes memory) {
return a;
}
function g() public returns (bytes memory) {
return b;
}
function h() public returns (uint) {
return c;
}
function i() public returns (bytes memory) {
return fre();
}
}
// ====
// compileViaYul: also
// ----
// f() -> 0x20, 3, "\x03\x01\x02"
// g() -> 0x20, 3, "\x03\x01\x02"
// h() -> 5
// i() -> 0x20, 3, "\x03\x01\x02"
@@ -0,0 +1,26 @@
==== Source: s1.sol ====
uint constant a = 89;
function fre() pure returns (uint) {
return a;
}
==== Source: s2.sol ====
import {a as b, fre} from "s1.sol";
import "s1.sol" as M;
uint256 constant a = 13;
contract C {
function f() public returns (uint, uint, uint, uint) {
return (a, fre(), M.a, b);
}
}
// ====
// compileViaYul: also
// ----
// f() -> 0x0d, 0x59, 0x59, 0x59
@@ -23,6 +23,8 @@ contract test {
return ret;
}
}
// ====
// compileViaYul: also
// ----
// f(bool): true -> 1
// f(bool): false -> 2
@@ -0,0 +1,15 @@
==== Source: a.sol ====
function f(uint) pure returns (uint) { return 7; }
function f(bytes memory x) pure returns (uint) { return x.length; }
==== Source: b.sol ====
import "a.sol" as M;
contract C {
function f() public pure returns (uint, uint) {
return (M.f(2), M.f("abc"));
}
}
// ====
// compileViaYul: also
// ----
// f() -> 7, 3
@@ -18,6 +18,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f() -> true
// a() -> 7
@@ -21,5 +21,7 @@ contract C {
return (s.f(), h(s));
}
}
// ====
// compileViaYul: also
// ----
// g() -> 7, 7
@@ -0,0 +1,26 @@
contract C {
struct S {
uint16 v;
S[] x;
}
uint8[77] padding;
S s;
constructor() {
s.v = 21;
s.x.push(); s.x.push(); s.x.push();
s.x[0].v = 101; s.x[1].v = 102; s.x[2].v = 103;
}
function f() public returns (uint256 a, uint256 b, uint256 c, uint256 d) {
S storage sptr1 = s.x[0];
S storage sptr2 = s.x[1];
S storage sptr3 = s.x[2];
uint256 slot1; uint256 slot2; uint256 slot3;
assembly { slot1 := sptr1.slot slot2 := sptr2.slot slot3 := sptr3.slot }
delete s;
assembly { a := sload(s.slot) b := sload(slot1) c := sload(slot2) d := sload(slot3) }
}
}
// ====
// compileViaYul: also
// ----
// f() -> 0, 0, 0, 0
@@ -15,5 +15,7 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f() -> 1
@@ -16,5 +16,7 @@ contract test {
}
}
// ====
// compileViaYul: also
// ----
// deleteMember() -> 0
@@ -0,0 +1,23 @@
contract C {
struct S {
uint256 x;
uint128 y;
uint32 z;
}
uint8 b = 23;
S s;
uint8 a = 17;
function f() public {
s.x = 42; s.y = 42; s.y = 42;
delete s;
assert(s.x == 0);
assert(s.y == 0);
assert(s.z == 0);
assert(b == 23);
assert(a == 17);
}
}
// ====
// compileViaYul: also
// ----
// f() ->
@@ -0,0 +1,47 @@
pragma experimental ABIEncoderV2;
contract C {
struct S {
uint128 a;
uint256[] x;
uint240 b;
}
uint8 b = 23;
S s;
uint8 a = 17;
function f() public {
delete s;
s.x.push(42); s.x.push(42); s.x.push(42);
delete s;
assert(s.x.length == 0);
uint256[] storage x = s.x;
assembly { sstore(x.slot, 3) }
assert(s.x[0] == 0);
assert(s.x[1] == 0);
assert(s.x[2] == 0);
assert(b == 23);
assert(a == 17);
}
function g() public {
delete s;
s.x.push(42); s.x.push(42); s.x.push(42);
s.a = 1; s.b = 2;
delete s.x;
assert(s.x.length == 0);
uint256[] storage x = s.x;
assembly { sstore(x.slot, 3) }
assert(s.x[0] == 0);
assert(s.x[1] == 0);
assert(s.x[2] == 0);
assert(b == 23);
assert(a == 17);
assert(s.a == 1);
assert(s.b == 2);
}
}
// ====
// compileViaYul: also
// ----
// f() ->
// g() ->
@@ -14,5 +14,7 @@ contract test {
}
}
// ====
// compileViaYul: also
// ----
// deleteIt() -> 0
@@ -18,6 +18,8 @@ contract test {
inner.recursive[0].z = inner.recursive[1].z + 1;
}
}
// ====
// compileViaYul: also
// ----
// check() -> false
// set() ->
@@ -22,5 +22,7 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f() -> true