Skip to content

Commit bd57de6

Browse files
committed
Document legacy and IR behavior for call to zero initialized variable of function type.
1 parent 311b205 commit bd57de6

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
contract Other {
2+
function addTwo(uint256 x) public returns (uint256) {
3+
return x + 2;
4+
}
5+
}
6+
contract C {
7+
function (function (uint) external returns (uint)) internal returns (uint) ev;
8+
function (uint) external returns (uint) x;
9+
10+
function store(function(uint) external returns (uint) y) public {
11+
x = y;
12+
}
13+
14+
function eval(function(uint) external returns (uint) y) public returns (uint) {
15+
return y(7);
16+
}
17+
18+
function t() public returns (uint256) {
19+
this.store((new Other()).addTwo);
20+
// This call panics
21+
return ev(x);
22+
}
23+
}
24+
// ====
25+
// compileViaYul: true
26+
// ----
27+
// t() -> FAILURE, hex"4e487b71", 0x51
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
contract Other {
2+
function addTwo(uint256 x) public returns (uint256) {
3+
return x + 2;
4+
}
5+
}
6+
contract C {
7+
function (function (uint) external returns (uint)) internal returns (uint) ev;
8+
function (uint) external returns (uint) x;
9+
10+
function store(function(uint) external returns (uint) y) public {
11+
x = y;
12+
}
13+
14+
function eval(function(uint) external returns (uint) y) public returns (uint) {
15+
return y(7);
16+
}
17+
18+
function t() public returns (uint256) {
19+
this.store((new Other()).addTwo);
20+
// This call panics
21+
return ev(x);
22+
}
23+
}
24+
// ====
25+
// compileViaYul: false
26+
// ----
27+
// t() -> FAILURE

0 commit comments

Comments
 (0)