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

30 lines
1.2 KiB
Solidity
Raw Normal View History

2020-03-02 20:42:46 +00:00
contract C {
function f(uint n, uint m) public {
function() internal returns (uint)[] memory arr = new function() internal returns (uint)[](n);
arr[m]();
}
function f2(uint n, uint m, uint a, uint b) public {
function() internal returns (uint)[][] memory arr = new function() internal returns (uint)[][](n);
for (uint i = 0; i < n; ++i)
arr[i] = new function() internal returns (uint)[](m);
arr[a][b]();
}
function g(uint n, uint m) public {
function() external returns (uint)[] memory arr = new function() external returns (uint)[](n);
arr[m]();
}
function g2(uint n, uint m, uint a, uint b) public {
function() external returns (uint)[][] memory arr = new function() external returns (uint)[][](n);
for (uint i = 0; i < n; ++i)
arr[i] = new function() external returns (uint)[](m);
arr[a][b]();
}
}
// ====
// compileViaYul: also
// ----
2021-02-12 12:45:15 +00:00
// f(uint256,uint256): 1823621, 12323 -> FAILURE # Out of gas #
// f2(uint256,uint256,uint256,uint256): 18723921, 1823621, 123, 12323 -> FAILURE # Out of gas #
// g(uint256,uint256): 1823621, 12323 -> FAILURE # Out of gas #
// g2(uint256,uint256,uint256,uint256): 18723921, 1823621, 123, 12323 -> FAILURE # Out of gas #