mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge remote-tracking branch 'origin/develop' into breaking
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
contract C {
|
||||
function f(uint16[3] memory a, uint16[2][3] memory b, uint i, uint j, uint k)
|
||||
public pure returns (uint, uint) {
|
||||
return (a[i], b[j][k]);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(uint16[3],uint16[2][3],uint256,uint256,uint256): 1, 2, 3, 11, 12, 21, 22, 31, 32, 1, 2, 1 -> 2, 32
|
||||
@@ -0,0 +1,10 @@
|
||||
contract C {
|
||||
function f(bool b) public pure returns (bool) { return b; }
|
||||
}
|
||||
// ====
|
||||
// ABIEncoderV1Only: true
|
||||
// ----
|
||||
// f(bool): true -> true
|
||||
// f(bool): false -> false
|
||||
// f(bool): 0x000000 -> false
|
||||
// f(bool): 0xffffff -> true
|
||||
@@ -0,0 +1,9 @@
|
||||
contract C {
|
||||
function f(uint a, uint[] calldata b, uint c) external pure returns (uint) {
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(uint256,uint256[],uint256): 6, 0x60, 9, 0x8000000000000000000000000000000000000000000000000000000000000002, 1, 2 -> FAILURE
|
||||
@@ -0,0 +1,16 @@
|
||||
contract C {
|
||||
function f(uint16 a, int16 b, address c, bytes3 d, bool e)
|
||||
public pure returns (uint v, uint w, uint x, uint y, uint z) {
|
||||
assembly { v := a w := b x := c y := d z := e}
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// ABIEncoderV1Only: true
|
||||
// ----
|
||||
// f(uint16,int16,address,bytes3,bool): 1, 2, 3, "a", true -> 1, 2, 3, "a", true
|
||||
// f(uint16,int16,address,bytes3,bool): 0xffffff, 0x1ffff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, "abcd", 1 -> 0xffff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xffffffffffffffffffffffffffffffffffffffff, "abc", true
|
||||
// f(uint16,int16,address,bytes3,bool): 0xffffff, 0, 0, "bcd", 1 -> 0xffff, 0, 0, "bcd", true
|
||||
// f(uint16,int16,address,bytes3,bool): 0, 0x1ffff, 0, "ab", 1 -> 0, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0, "ab", true
|
||||
// f(uint16,int16,address,bytes3,bool): 0, 0, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, "ad", 1 -> 0, 0, 0xffffffffffffffffffffffffffffffffffffffff, "ad", true
|
||||
// f(uint16,int16,address,bytes3,bool): 0, 0, 0, "abcd", 1 -> 0, 0, 0, "abc", true
|
||||
// f(uint16,int16,address,bytes3,bool): 0, 0, 0, "abc", 2 -> 0, 0, 0, "abc", true
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
contract C {
|
||||
function dyn() public returns (bytes memory a, uint b, bytes20[] memory c, uint d) {
|
||||
a = "1234567890123456789012345678901234567890";
|
||||
b = type(uint).max;
|
||||
c = new bytes20[](4);
|
||||
c[0] = bytes20(uint160(1234));
|
||||
c[3] = bytes20(uint160(6789));
|
||||
d = 0x1234;
|
||||
}
|
||||
function f() public returns (bytes memory, uint, bytes20[] memory, uint) {
|
||||
return this.dyn();
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// EVMVersion: >homestead
|
||||
// ----
|
||||
// f() -> 0x80, -1, 0xe0, 0x1234, 40, "12345678901234567890123456789012", "34567890", 4, 97767552542602192590433234714624, 0, 0, 537879995309340587922569878831104
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
contract C {
|
||||
function dyn(uint x) public returns (bytes memory a) {
|
||||
assembly {
|
||||
mstore(0, 0x20)
|
||||
mstore(0x20, 0x21)
|
||||
return(0, x)
|
||||
}
|
||||
}
|
||||
function f(uint x) public returns (bool) {
|
||||
this.dyn(x);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// EVMVersion: =homestead
|
||||
// ----
|
||||
// f(uint256): 0x60 -> true
|
||||
// f(uint256): 0x7f -> true
|
||||
// f(uint256): 0x80 -> true
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
contract C {
|
||||
function dyn(uint x) public returns (bytes memory a) {
|
||||
assembly {
|
||||
mstore(0, 0x20)
|
||||
mstore(0x20, 0x21)
|
||||
return(0, x)
|
||||
}
|
||||
}
|
||||
function f(uint x) public returns (bool) {
|
||||
this.dyn(x);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// EVMVersion: >homestead
|
||||
// ----
|
||||
// f(uint256): 0x60 -> FAILURE
|
||||
// f(uint256): 0x61 -> true
|
||||
// f(uint256): 0x80 -> true
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
contract C {
|
||||
function dyn() public returns (bytes memory) {
|
||||
return "1234567890123456789012345678901234567890";
|
||||
}
|
||||
function f() public returns (bytes memory) {
|
||||
return this.dyn();
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// EVMVersion: >homestead
|
||||
// ----
|
||||
// f() -> 0x20, 40, "12345678901234567890123456789012", "34567890"
|
||||
@@ -0,0 +1,26 @@
|
||||
library L {
|
||||
struct S { uint x; uint y; }
|
||||
function f(uint[] storage r, S storage s) public returns (uint, uint, uint, uint) {
|
||||
r[2] = 8;
|
||||
s.x = 7;
|
||||
return (r[0], r[1], s.x, s.y);
|
||||
}
|
||||
}
|
||||
contract C {
|
||||
uint8 x = 3;
|
||||
L.S s;
|
||||
uint[] r;
|
||||
function f() public returns (uint, uint, uint, uint, uint, uint) {
|
||||
r = new uint[](6);
|
||||
r[0] = 1;
|
||||
r[1] = 2;
|
||||
r[2] = 3;
|
||||
s.x = 11;
|
||||
s.y = 12;
|
||||
(uint a, uint b, uint c, uint d) = L.f(r, s);
|
||||
return (r[2], s.x, a, b, c, d);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// library: L
|
||||
// f() -> 8, 7, 1, 2, 7, 12
|
||||
@@ -0,0 +1,12 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract C {
|
||||
function f(bool b) public pure returns (bool) { return b; }
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(bool): true -> true
|
||||
// f(bool): false -> false
|
||||
// f(bool): 0x000000 -> false
|
||||
// f(bool): 0xffffff -> FAILURE
|
||||
@@ -25,6 +25,8 @@ contract C {
|
||||
return reenc ? this.f_reenc(a) : this.f(a);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// g(bool): false -> 23, 37, 71
|
||||
// g(bool): true -> 23, 37, 71
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract C {
|
||||
function f(uint16 a, int16 b, address c, bytes3 d, bool e)
|
||||
public pure returns (uint v, uint w, uint x, uint y, uint z) {
|
||||
assembly { v := a w := b x := c y := d z := e}
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(uint16,int16,address,bytes3,bool): 1, 2, 3, "a", true -> 1, 2, 3, "a", true
|
||||
// f(uint16,int16,address,bytes3,bool): 0xffffff, 0x1ffff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, "abcd", 1 -> FAILURE
|
||||
// f(uint16,int16,address,bytes3,bool): 0xffffff, 0, 0, "bcd", 1 -> FAILURE
|
||||
// f(uint16,int16,address,bytes3,bool): 0, 0x1ffff, 0, "ab", 1 -> FAILURE
|
||||
// f(uint16,int16,address,bytes3,bool): 0, 0, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, "ad", 1 -> FAILURE
|
||||
// f(uint16,int16,address,bytes3,bool): 0, 0, 0, "abcd", 1 -> FAILURE
|
||||
// f(uint16,int16,address,bytes3,bool): 0, 0, 0, "abc", 2 -> FAILURE
|
||||
@@ -0,0 +1,14 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract C {
|
||||
struct S { C c; uint[] x; }
|
||||
function f(uint a, S[2] memory s1, uint b) public returns (uint r1, C r2, uint r3) {
|
||||
r1 = a;
|
||||
r2 = s1[0].c;
|
||||
r3 = b;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(uint256,(address,uint256[])[2],uint256): 7, 0x60, 8, 0x40, 0xE0, 0x0, 0x40, 2, 0x11, 0x12, 0x99, 0x40, 4, 0x31, 0x32, 0x34, 0x35 -> 7, 0x0, 8
|
||||
@@ -0,0 +1,14 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract C {
|
||||
struct S { C c; }
|
||||
function f(uint a, S[2] memory s1, uint b) public returns (uint r1, C r2, uint r3) {
|
||||
r1 = a;
|
||||
r2 = s1[0].c;
|
||||
r3 = b;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(uint256,(address)[2],uint256): 7, 0, 0, 8 -> 7, 0, 8
|
||||
@@ -0,0 +1,16 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract C {
|
||||
struct S { function () external returns (uint) f; uint b; }
|
||||
function f(S memory s) public returns (uint, uint) {
|
||||
return (s.f(), s.b);
|
||||
}
|
||||
function test() public returns (uint, uint) {
|
||||
return this.f(S(this.g, 3));
|
||||
}
|
||||
function g() public returns (uint) { return 7; }
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// test() -> 7, 3
|
||||
@@ -0,0 +1,13 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract C {
|
||||
struct S { int a; uint b; bytes16 c; }
|
||||
function f(S memory s) public pure returns (S memory q) {
|
||||
q = s;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f((int256,uint256,bytes16)): 0xff010, 0xff0002, "abcd" -> 0xff010, 0xff0002, "abcd"
|
||||
// f((int256,uint256,bytes16)): 0xff010, 0xff0002, 0x1111222233334444555566667777888800000000000000000000000000000000 -> 0xff010, 0xff0002, left(0x11112222333344445555666677778888)
|
||||
@@ -0,0 +1,15 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract C {
|
||||
struct S { uint a; uint8 b; uint8 c; bytes2 d; }
|
||||
function f(S memory s) public pure returns (uint a, uint b, uint c, uint d) {
|
||||
a = s.a;
|
||||
b = s.b;
|
||||
c = s.c;
|
||||
d = uint16(s.d);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f((uint256,uint8,uint8,bytes2)): 1, 2, 3, "ab" -> 1, 2, 3, 0x6162
|
||||
@@ -0,0 +1,19 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract C {
|
||||
struct S { int16 a; uint8 b; bytes2 c; }
|
||||
function f(S memory s) public pure returns (uint a, uint b, uint c) {
|
||||
assembly {
|
||||
a := mload(s)
|
||||
b := mload(add(s, 0x20))
|
||||
c := mload(add(s, 0x40))
|
||||
}
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f((int16,uint8,bytes2)): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01, 0xff, "ab" -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01, 0xff, "ab"
|
||||
// f((int16,uint8,bytes2)): 0xff010, 0xff, "ab" -> FAILURE
|
||||
// f((int16,uint8,bytes2)): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01, 0xff0002, "ab" -> FAILURE
|
||||
// f((int16,uint8,bytes2)): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01, 0xff, "abcd" -> FAILURE
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract C {
|
||||
struct S { function () external x; }
|
||||
function f(S memory) public pure returns (uint r) { r = 1; }
|
||||
function g(S calldata) external pure returns (uint r) { r = 2; }
|
||||
function h(S calldata s) external pure returns (uint r) { s.x; r = 3; }
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f((function)): "01234567890123456789abcd" -> 1
|
||||
// f((function)): "01234567890123456789abcdX" -> FAILURE
|
||||
// g((function)): "01234567890123456789abcd" -> 2
|
||||
// g((function)): "01234567890123456789abcdX" -> 2
|
||||
// h((function)): "01234567890123456789abcd" -> 3
|
||||
// h((function)): "01234567890123456789abcdX" -> FAILURE
|
||||
@@ -17,6 +17,8 @@ contract test {
|
||||
return (a[0], a[1], a[2], b[0], b[1], b[2]);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// g() -> 0, 42, 0, 0, 84, 21
|
||||
// h() -> 0, 42, 0, 0, 84, 17
|
||||
|
||||
@@ -12,6 +12,7 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// EVMVersion: >=tangerineWhistle
|
||||
// ----
|
||||
// f() -> true
|
||||
|
||||
@@ -17,6 +17,7 @@ contract A {
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// EVMVersion: >=constantinople
|
||||
// ----
|
||||
// different_salt() -> true
|
||||
|
||||
@@ -26,6 +26,7 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// EVMVersion: >=byzantium
|
||||
// ----
|
||||
// f() -> 0, 0, 96, 13, "test message."
|
||||
|
||||
Reference in New Issue
Block a user