mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
159f50e189
These were marked IR-only, but they do pass on the old codegen too. Also add old codegen version of semantictests/revertStrings/function_entry_checks.
36 lines
899 B
Solidity
36 lines
899 B
Solidity
contract C {
|
|
function index(uint256 len) public returns (bool)
|
|
{
|
|
uint[] memory array = new uint[](len);
|
|
|
|
for (uint256 i = 0; i < len; i++)
|
|
array[i] = i + 1;
|
|
|
|
for (uint256 i = 0; i < len; i++)
|
|
require(array[i] == i + 1, "Unexpected value in array!");
|
|
|
|
return array.length == len;
|
|
}
|
|
function accessIndex(uint256 len, int256 idx) public returns (uint256)
|
|
{
|
|
uint[] memory array = new uint[](len);
|
|
|
|
for (uint256 i = 0; i < len; i++)
|
|
array[i] = i + 1;
|
|
|
|
return array[uint256(idx)];
|
|
}
|
|
}
|
|
// ====
|
|
// compileViaYul: also
|
|
// ----
|
|
// index(uint256): 0 -> true
|
|
// index(uint256): 10 -> true
|
|
// index(uint256): 20 -> true
|
|
// index(uint256): 0xFF -> true
|
|
// accessIndex(uint256,int256): 10,1 -> 2
|
|
// accessIndex(uint256,int256): 10,0 -> 1
|
|
// accessIndex(uint256,int256): 10,11 -> FAILURE
|
|
// accessIndex(uint256,int256): 10,10 -> FAILURE
|
|
// accessIndex(uint256,int256): 10,-1 -> FAILURE
|