solidity/test/libsolidity/semanticTests/viaYul/calldata_array_access.sol

21 lines
799 B
Solidity
Raw Normal View History

2020-11-23 18:06:44 +00:00
pragma abicoder v2;
2020-02-11 16:43:43 +00:00
contract C {
function f(uint256[] calldata x, uint256 i) external returns (uint256) {
return x[i];
}
function f(uint256[][] calldata x, uint256 i, uint256 j) external returns (uint256) {
return x[i][j];
}
}
// ====
// compileViaYul: also
// ----
2020-10-13 11:28:39 +00:00
// f(uint256[],uint256): 0x40, 0, 0 -> FAILURE, hex"4e487b71", 0x32
2020-02-11 16:43:43 +00:00
// f(uint256[],uint256): 0x40, 0, 1, 23 -> 23
2020-10-13 11:28:39 +00:00
// f(uint256[],uint256): 0x40, 1, 1, 23 -> FAILURE, hex"4e487b71", 0x32
2020-02-11 16:43:43 +00:00
// f(uint256[],uint256): 0x40, 0, 2, 23, 42 -> 23
// f(uint256[],uint256): 0x40, 1, 2, 23, 42 -> 42
2020-10-13 11:28:39 +00:00
// f(uint256[],uint256): 0x40, 2, 2, 23, 42 -> FAILURE, hex"4e487b71", 0x32
2020-02-11 16:43:43 +00:00
// f(uint256[][],uint256,uint256): 0x60, 0, 0 -> FAILURE
// f(uint256[][],uint256,uint256): 0x60, 0, 0, 1, 0x20, 1, 23 -> 23