-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: the uninit function pointer test
- Loading branch information
1 parent
d5cbdf1
commit dde0651
Showing
2 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
solidity/simple/internal_function_pointers/call_to_zero_initialized_function_type_legacy.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...y/simple/internal_function_pointers/call_to_zero_initialized_function_type_legacy_evm.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
//! { "targets": [ "EVM" ], "modes": [ "I", "Y" ], "cases": [ { | ||
//! "name": "default", | ||
//! "inputs": [ | ||
//! { | ||
//! "method": "t", | ||
//! "calldata": [] | ||
//! } | ||
//! ], | ||
//! "expected": { | ||
//! "return_data": [ | ||
//! "0x4e487b7100000000000000000000000000000000000000000000000000000000", | ||
//! "0x0000005100000000000000000000000000000000000000000000000000000000" | ||
//! ], | ||
//! "exception": true | ||
//! } | ||
//! } ] } | ||
|
||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity >=0.8.0; | ||
|
||
// This tests is an addendum to `tests/solidity/ethereum/functionTypes/call_to_zero_initialized_function_type_legacy.sol` | ||
// and covers the return data for Solidity >=0.8 where the error is not empty. | ||
|
||
contract Other { | ||
function addTwo(uint256 x) public returns (uint256) { | ||
return x + 2; | ||
} | ||
} | ||
|
||
contract Test { | ||
function (function (uint) external returns (uint)) internal returns (uint) ev; | ||
function (uint) external returns (uint) x; | ||
|
||
function store(function(uint) external returns (uint) y) public { | ||
x = y; | ||
} | ||
|
||
function eval(function(uint) external returns (uint) y) public returns (uint) { | ||
return y(7); | ||
} | ||
|
||
function t() public returns (uint256) { | ||
this.store((new Other()).addTwo); | ||
// This call panics | ||
return ev(x); | ||
} | ||
} |