mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
41ce3feb0a
1. `push0_disallowed.yul`: checks if `push0()` is a valid builtin in strict Yul 2. `push0_disallowed.sol`: checks if `push0()` is a valid builtin in inline assembly 3. `push0.sol`: simple semantic test that returns 0 4. `evmone_support.sol`: tests if push0 works properly in evmone 5. Updated some bytecode too large tests to use `shanghai` as version 6. Updated various tests where `push1 0` was hardcoded in different forms / expectations on bytecode size (`Assembler.cpp`, `GasCosts.cpp`, `SolidityCompiler.cpp`, `SolidityExpressionCompiler.cpp`)
32 lines
827 B
Solidity
32 lines
827 B
Solidity
contract ShortReturn {
|
|
constructor() {
|
|
assembly {
|
|
// return(0, 32)
|
|
// PUSH1 0x20 PUSH0 RETURN
|
|
mstore(0, hex"60205ff3")
|
|
return(0, 4)
|
|
}
|
|
}
|
|
}
|
|
|
|
interface DoesItReturnZero {
|
|
function foo() external pure returns (uint256);
|
|
}
|
|
|
|
contract Test {
|
|
ShortReturn immutable shortReturn = new ShortReturn();
|
|
function bytecode() external view returns(bytes memory) {
|
|
return address(shortReturn).code;
|
|
}
|
|
function isPush0Supported() external view returns (bool) {
|
|
assert(DoesItReturnZero(address(shortReturn)).foo() == 0);
|
|
return true;
|
|
}
|
|
}
|
|
// ====
|
|
// compileViaYul: also
|
|
// EVMVersion: >=shanghai
|
|
// ----
|
|
// bytecode() -> 0x20, 4, 0x60205ff300000000000000000000000000000000000000000000000000000000
|
|
// isPush0Supported() -> true
|