From d92ed3fd294e3b0cc469b3b536cd10cf3873ce8d Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Thu, 7 Apr 2022 13:37:48 +0200 Subject: [PATCH] Test case for the buggy behaviour. --- .../calldata_nested_array_reencode.sol | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 test/libsolidity/semanticTests/abiEncoderV2/calldata_nested_array_reencode.sol diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_nested_array_reencode.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_nested_array_reencode.sol new file mode 100644 index 000000000..d7ff1999b --- /dev/null +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_nested_array_reencode.sol @@ -0,0 +1,23 @@ +pragma abicoder v2; + +contract C { + function h(uint[][] calldata a) public { + abi.encode(a); + } + struct S { uint[] x; } + function f(S calldata a) public { + abi.encode(a); + } +} +// ==== +// compileViaYul: also +// revertStrings: debug +// ---- +// h(uint256[][]): 0x20, 1, 0x20, 0 -> +// h(uint256[][]): 0x20, 1, 0x20, 1 -> +// h(uint256[][]): 0x20, 1, 0x20, 2 -> +// h(uint256[][]): 0x20, 1, 0x20, 3 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access stride" +// f((uint256[])): 0x20, 0x20, 0 -> +// f((uint256[])): 0x20, 0x20, 1 -> +// f((uint256[])): 0x20, 0x20, 2 -> +// f((uint256[])): 0x20, 0x20, 3 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access stride"