mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Support copying of nested calldata arrays to memory.
This commit is contained in:
@@ -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
|
||||
@@ -10,4 +10,3 @@ contract Test {
|
||||
}
|
||||
|
||||
// ----
|
||||
// UnimplementedFeatureError: Copying nested dynamic calldata arrays to memory is not implemented in the old code generator.
|
||||
|
||||
@@ -10,4 +10,3 @@ contract Test {
|
||||
}
|
||||
|
||||
// ----
|
||||
// UnimplementedFeatureError: Copying nested dynamic calldata arrays to memory is not implemented in the old code generator.
|
||||
|
||||
@@ -10,4 +10,3 @@ contract Test {
|
||||
}
|
||||
|
||||
// ----
|
||||
// UnimplementedFeatureError: Copying nested dynamic calldata arrays to memory is not implemented in the old code generator.
|
||||
|
||||
Reference in New Issue
Block a user