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:
+19
@@ -0,0 +1,19 @@
|
||||
contract c {
|
||||
uint64[] data1;
|
||||
uint256[] data2;
|
||||
|
||||
function test() public returns (uint256 x, uint256 y) {
|
||||
data2.push(11);
|
||||
data1.push(0);
|
||||
data1.push(1);
|
||||
data1.push(2);
|
||||
data1.push(3);
|
||||
data1.push(4);
|
||||
data2 = data1;
|
||||
assert(data1[0] == data2[0]);
|
||||
x = data2.length;
|
||||
y = data2[4];
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// test() -> 5, 4
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
contract c {
|
||||
uint256[] data1;
|
||||
uint256[] data2;
|
||||
|
||||
function test() public returns (uint256 x, uint256 y) {
|
||||
data2.push(11);
|
||||
data1.push(0);
|
||||
data1.push(1);
|
||||
data1.push(2);
|
||||
data1.push(3);
|
||||
data1.push(4);
|
||||
data2 = data1;
|
||||
assert(data1[0] == data2[0]);
|
||||
x = data2.length;
|
||||
y = data2[4];
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// test() -> 5, 4
|
||||
+2
@@ -13,5 +13,7 @@ contract c {
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// test() -> 8, 0
|
||||
|
||||
@@ -30,7 +30,7 @@ contract c {
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: true
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// test1(uint256[][]): 0x20, 2, 0x40, 0x40, 2, 23, 42 -> 2, 65
|
||||
// test2(uint256[][2]): 0x20, 0x40, 0x40, 2, 23, 42 -> 2, 65
|
||||
|
||||
+1
-1
@@ -18,6 +18,6 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: true
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f((uint256[])[]): 0x20, 3, 0x60, 0x60, 0x60, 0x20, 3, 1, 2, 3 -> 3, 1
|
||||
@@ -0,0 +1,14 @@
|
||||
pragma abicoder v2;
|
||||
|
||||
contract C {
|
||||
function g(bytes[2] memory m) internal returns (bytes memory) {
|
||||
return m[0];
|
||||
}
|
||||
function f(bytes[2] calldata c) external returns (bytes memory) {
|
||||
return g(c);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(bytes[2]): 0x20, 0x40, 0x40, 2, "ab" -> 0x20, 2, "ab"
|
||||
@@ -0,0 +1,18 @@
|
||||
pragma abicoder v2;
|
||||
|
||||
contract C {
|
||||
function g(bytes[2] memory m) internal {
|
||||
assert(m[0].length > 1);
|
||||
assert(m[1].length > 1);
|
||||
assert(m[0][0] == m[1][0]);
|
||||
assert(m[0][1] == m[1][1]);
|
||||
}
|
||||
function f(bytes[2] calldata c) external {
|
||||
g(c);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(bytes[2]): 0x20, 0x40, 0x40, 2, "ab" ->
|
||||
// f(bytes[2]): 0x20, 0x40, 0x40, 1, "a" -> FAILURE
|
||||
@@ -0,0 +1,14 @@
|
||||
pragma abicoder v2;
|
||||
|
||||
contract Test {
|
||||
struct shouldBug {
|
||||
uint256[][2] deadly;
|
||||
}
|
||||
function killer(uint256[][2] calldata weapon) pure external returns (shouldBug memory) {
|
||||
return shouldBug(weapon);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// killer(uint256[][2]): 0x20, 0x40, 0x40, 2, 1, 2 -> 0x20, 0x20, 0x40, 0xa0, 2, 1, 2, 2, 1, 2
|
||||
@@ -11,10 +11,23 @@ contract C {
|
||||
function f() public m returns (bool) {
|
||||
return true;
|
||||
}
|
||||
|
||||
modifier n {
|
||||
uint256 a = 1;
|
||||
assembly {
|
||||
a := 2
|
||||
}
|
||||
if (a != 2)
|
||||
_;
|
||||
revert();
|
||||
}
|
||||
|
||||
function g() public n returns (bool) {
|
||||
// This statement should never execute.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// compileToEwasm: also
|
||||
// ----
|
||||
// f() -> true
|
||||
// g() -> FAILURE
|
||||
|
||||
@@ -3,7 +3,8 @@ contract C {
|
||||
modifier run() {
|
||||
for (uint256 i = 0; i < 10; i++) {
|
||||
_;
|
||||
break;
|
||||
if (i == 1)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,10 +14,7 @@ contract C {
|
||||
x = t;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// compileToEwasm: also
|
||||
// ----
|
||||
// x() -> 0
|
||||
// f() ->
|
||||
// x() -> 1
|
||||
// x() -> 2
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
contract C {
|
||||
uint256 public x;
|
||||
modifier run() {
|
||||
modifier m() {
|
||||
for (uint256 i = 0; i < 10; i++) {
|
||||
_;
|
||||
break;
|
||||
++x;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function f() public run {
|
||||
uint256 k = x;
|
||||
uint256 t = k + 1;
|
||||
x = t;
|
||||
function f() public m m m returns (uint) {
|
||||
for (uint256 i = 0; i < 10; i++) {
|
||||
++x;
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// compileToEwasm: also
|
||||
// ----
|
||||
// x() -> 0
|
||||
// f() ->
|
||||
// x() -> 1
|
||||
// f() -> 42
|
||||
// x() -> 4
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
contract C {
|
||||
modifier tryCircumvent {
|
||||
if (false) _; // avoid the function, we should still not accept ether
|
||||
}
|
||||
function f() tryCircumvent public returns (uint) {
|
||||
return msgvalue();
|
||||
}
|
||||
function msgvalue() internal returns (uint) {
|
||||
return msg.value;
|
||||
}
|
||||
// TODO: remove this helper function once isoltest supports balance checking
|
||||
function balance() external returns (uint) {
|
||||
return address(this).balance;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// f(), 27 wei -> FAILURE
|
||||
// balance() -> 0
|
||||
@@ -1,4 +1,4 @@
|
||||
pragma abicoder v2;
|
||||
pragma abicoder v2;
|
||||
|
||||
|
||||
contract C {
|
||||
@@ -19,6 +19,7 @@ contract C {
|
||||
c = s.c;
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f((uint256,uint256[2],uint256)): 42, 1, 2, 23 -> 42, 1, 2, 23
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
pragma abicoder v2;
|
||||
|
||||
contract C {
|
||||
struct S {
|
||||
uint32 a;
|
||||
uint256[] b;
|
||||
uint64 c;
|
||||
}
|
||||
|
||||
function f(S calldata s)
|
||||
external
|
||||
pure
|
||||
returns (uint32 a, uint256 b0, uint256 b1, uint64 c)
|
||||
{
|
||||
a = s.a;
|
||||
b0 = s.b[0];
|
||||
b1 = s.b[1];
|
||||
c = s.c;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f((uint32,uint256[],uint64)): 0x20, 42, 0x60, 23, 2, 1, 2 -> 42, 1, 2, 23
|
||||
@@ -0,0 +1,28 @@
|
||||
pragma abicoder v2;
|
||||
|
||||
contract C {
|
||||
struct S {
|
||||
uint64 a;
|
||||
uint64 b;
|
||||
}
|
||||
struct S1 {
|
||||
uint256 a;
|
||||
S s;
|
||||
uint256 c;
|
||||
}
|
||||
|
||||
function f(S1 calldata s1)
|
||||
external
|
||||
pure
|
||||
returns (uint256 a, uint64 b0, uint64 b1, uint256 c)
|
||||
{
|
||||
a = s1.a;
|
||||
b0 = s1.s.a;
|
||||
b1 = s1.s.b;
|
||||
c = s1.c;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f((uint256,(uint64, uint64),uint256)): 42, 1, 2, 23 -> 42, 1, 2, 23
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
pragma abicoder v2;
|
||||
|
||||
contract C {
|
||||
struct S {
|
||||
uint64 a;
|
||||
bytes b;
|
||||
}
|
||||
struct S1 {
|
||||
uint256 a;
|
||||
S s;
|
||||
uint256 c;
|
||||
}
|
||||
|
||||
function f(S1 calldata s1)
|
||||
external
|
||||
pure
|
||||
returns (uint256 a, uint64 b0, byte b1, uint256 c)
|
||||
{
|
||||
a = s1.a;
|
||||
b0 = s1.s.a;
|
||||
b1 = s1.s.b[0];
|
||||
c = s1.c;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f((uint256,(uint64, bytes),uint256)): 0x20, 42, 0x60, 23, 1, 0x40, 2, "ab" -> 42, 1, "a", 23
|
||||
@@ -15,5 +15,7 @@ contract C {
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() -> true
|
||||
|
||||
@@ -22,5 +22,7 @@ contract C {
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f((uint256,uint256,(uint256,uint256),uint256)): 1, 2, 3, 4, 5 -> 1, 2, 3, 4, 5
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
contract C {
|
||||
function conv(bytes25 a) public pure returns (bytes32) {
|
||||
// truncating and widening
|
||||
return ~bytes32(bytes16(~a));
|
||||
}
|
||||
|
||||
function upcast(bytes25 a) public pure returns (bytes32) {
|
||||
// implicit widening is allowed
|
||||
return ~a;
|
||||
}
|
||||
|
||||
function downcast(bytes25 a) public pure returns (bytes12) {
|
||||
// truncating cast must be explicit
|
||||
return bytes12(~a);
|
||||
}
|
||||
|
||||
function r_b32() public pure returns (bytes32) {
|
||||
return ~bytes32(hex"ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00");
|
||||
}
|
||||
function r_b25() public pure returns (bytes25) {
|
||||
return ~bytes25(hex"ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff");
|
||||
}
|
||||
function r_b16() public pure returns (bytes16) {
|
||||
return ~bytes16(hex"ff00ff00ff00ff00ff00ff00ff00ff00");
|
||||
}
|
||||
function r_b8() public pure returns (bytes8) {
|
||||
return ~bytes8(hex"ff00ff00ff00ff00");
|
||||
}
|
||||
function r_b4() public pure returns (bytes4) {
|
||||
return ~bytes4(hex"ff00ff00");
|
||||
}
|
||||
function r_b1() public pure returns (bytes1) {
|
||||
return ~bytes1(hex"55");
|
||||
}
|
||||
function r_b() public pure returns (byte) {
|
||||
return ~byte(hex"55");
|
||||
}
|
||||
|
||||
function a_b32() public pure returns (bytes32) {
|
||||
bytes32 r = ~bytes32(hex"ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00");
|
||||
return r;
|
||||
}
|
||||
function a_b25() public pure returns (bytes25) {
|
||||
bytes25 r = ~bytes25(hex"ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff");
|
||||
return r;
|
||||
}
|
||||
function a_b16() public pure returns (bytes16) {
|
||||
bytes16 r = ~bytes16(hex"ff00ff00ff00ff00ff00ff00ff00ff00");
|
||||
return r;
|
||||
}
|
||||
function a_b8() public pure returns (bytes8) {
|
||||
bytes8 r = ~bytes8(hex"ff00ff00ff00ff00");
|
||||
return r;
|
||||
}
|
||||
function a_b4() public pure returns (bytes4) {
|
||||
bytes4 r = ~bytes4(hex"ff00ff00");
|
||||
return r;
|
||||
}
|
||||
function a_b1() public pure returns (byte) {
|
||||
bytes1 r = ~bytes1(hex"55");
|
||||
return r;
|
||||
}
|
||||
function a_b() public pure returns (byte) {
|
||||
byte r = ~byte(hex"55");
|
||||
return r;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// conv(bytes25): left(0xff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff) -> 0xff00ff00ff00ff00ff00ff00ff00ff00ffffffffffffffffffffffffffffffff
|
||||
// upcast(bytes25): left(0xff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff) -> 0xff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff0000000000000000
|
||||
// downcast(bytes25): left(0xff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff) -> 0xff00ff00ff00ff00ff00ff0000000000000000000000000000000000000000
|
||||
// r_b32() -> 0xff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff
|
||||
// r_b25() -> 0xff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff0000000000000000
|
||||
// r_b16() -> 0xff00ff00ff00ff00ff00ff00ff00ff00000000000000000000000000000000
|
||||
// r_b8() -> 0xff00ff00ff00ff000000000000000000000000000000000000000000000000
|
||||
// r_b4() -> 0xff00ff00000000000000000000000000000000000000000000000000000000
|
||||
// r_b1() -> 0xaa00000000000000000000000000000000000000000000000000000000000000
|
||||
// r_b() -> 0xaa00000000000000000000000000000000000000000000000000000000000000
|
||||
// a_b32() -> 0xff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff
|
||||
// a_b25() -> 0xff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff0000000000000000
|
||||
// a_b16() -> 0xff00ff00ff00ff00ff00ff00ff00ff00000000000000000000000000000000
|
||||
// a_b8() -> 0xff00ff00ff00ff000000000000000000000000000000000000000000000000
|
||||
// a_b4() -> 0xff00ff00000000000000000000000000000000000000000000000000000000
|
||||
// a_b1() -> 0xaa00000000000000000000000000000000000000000000000000000000000000
|
||||
// a_b() -> 0xaa00000000000000000000000000000000000000000000000000000000000000
|
||||
Reference in New Issue
Block a user