Merge pull request #9320 from ethereum/tests_for_memory_in_external.sol

Tests for memory in external functions.
This commit is contained in:
chriseth 2020-07-07 11:05:50 +02:00 committed by GitHub
commit 2e9933b0de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,18 @@
contract C {
function f(bytes memory a, bytes calldata b, uint[] memory c)
external
pure
returns (uint, byte, uint, byte, uint, uint)
{
return (a.length, a[1], b.length, b[2], c.length, c[3]);
}
function g() public returns (uint, byte, uint, byte, uint, uint) {
uint[] memory x = new uint[](4);
x[3] = 7;
return this.f("abc", "def", x);
}
}
// ====
// compileViaYul: also
// ----
// g() -> 3, 0x6200000000000000000000000000000000000000000000000000000000000000, 3, 0x6600000000000000000000000000000000000000000000000000000000000000, 4, 7

View File

@ -0,0 +1,20 @@
pragma experimental ABIEncoderV2;
contract C {
function f(bytes memory a, bytes calldata b, uint[] memory c)
external
pure
returns (uint, byte, uint, byte, uint, uint)
{
return (a.length, a[1], b.length, b[2], c.length, c[3]);
}
function g() public returns (uint, byte, uint, byte, uint, uint) {
uint[] memory x = new uint[](4);
x[3] = 7;
return this.f("abc", "def", x);
}
}
// ====
// compileViaYul: also
// ----
// g() -> 3, 0x6200000000000000000000000000000000000000000000000000000000000000, 3, 0x6600000000000000000000000000000000000000000000000000000000000000, 4, 7