diff --git a/test/libsolidity/semanticTests/abiEncoderV1/memory_params_in_external_function.sol b/test/libsolidity/semanticTests/abiEncoderV1/memory_params_in_external_function.sol new file mode 100644 index 000000000..b0ba6dfaf --- /dev/null +++ b/test/libsolidity/semanticTests/abiEncoderV1/memory_params_in_external_function.sol @@ -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 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/memory_params_in_external_function.sol b/test/libsolidity/semanticTests/abiEncoderV2/memory_params_in_external_function.sol new file mode 100644 index 000000000..6c4845403 --- /dev/null +++ b/test/libsolidity/semanticTests/abiEncoderV2/memory_params_in_external_function.sol @@ -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