-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix handling of higher-order functions.
- Loading branch information
1 parent
fe37f60
commit bf4e3de
Showing
17 changed files
with
280 additions
and
4 deletions.
There are no files selected for viewing
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
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
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
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
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
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,19 @@ | ||
contract A { | ||
uint256 internal a; | ||
|
||
function fool(int256 b) external pure { | ||
b = b + 1; | ||
} | ||
|
||
// somfunc is `internal` | ||
function hof(function(int256) somfunc, int256 x) internal pure { | ||
x = x + 1; | ||
} | ||
|
||
function useHof() public { | ||
// `external` functions cannot be passed to functions expecting `internal` (even with `this`) | ||
hof(fool, 10); | ||
hof(this.fool, 10); | ||
a = 1 + 1; | ||
} | ||
} |
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,17 @@ | ||
contract A { | ||
uint256 internal a; | ||
|
||
function fool(int256 b) internal pure { | ||
b = b + 1; | ||
} | ||
|
||
function hof(function(int256) external somfunc, int256 x) internal pure { | ||
x = x + 1; | ||
} | ||
|
||
function useHof() public { | ||
// `internal` functions cannot be passed to functions expecting `external` | ||
hof(fool, 10); | ||
a = 1 + 1; | ||
} | ||
} |
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,17 @@ | ||
contract A { | ||
uint256 internal a; | ||
|
||
function fool(int256 b) private pure { | ||
b = b + 1; | ||
} | ||
|
||
function hof(function(int256) external somfunc, int256 x) internal pure { | ||
x = x + 1; | ||
} | ||
|
||
function useHof() public { | ||
// `private` functions cannot be passed to functions expecting `external` | ||
hof(fool, 10); | ||
a = 1 + 1; | ||
} | ||
} |
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,12 @@ | ||
contract A { | ||
uint256 internal a; | ||
|
||
function fool(int256 b) internal pure { | ||
b = b + 1; | ||
} | ||
|
||
// `external` functions cannot have `internal` function-type arguments | ||
function hof(function(int256) internal somfunc, int256 x) external pure { | ||
x = x + 1; | ||
} | ||
} |
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,12 @@ | ||
contract A { | ||
uint256 internal a; | ||
|
||
function fool(int256 b) internal pure { | ||
b = b + 1; | ||
} | ||
|
||
// `public` functions cannot have `internal` function-type arguments | ||
function hof(function(int256) internal somfunc, int256 x) public pure { | ||
x = x + 1; | ||
} | ||
} |
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,18 @@ | ||
contract A { | ||
uint256 internal a; | ||
|
||
function fool(int256 b) public pure { | ||
b = b + 1; | ||
} | ||
|
||
// somfunc is `internal` | ||
function hof(function(int256) somfunc, int256 x) internal pure { | ||
x = x + 1; | ||
} | ||
|
||
function useHof() public { | ||
// `public` functions can be passed to functions expecting `internal` | ||
hof(fool, 10); | ||
a = 1 + 1; | ||
} | ||
} |
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,18 @@ | ||
contract A { | ||
uint256 internal a; | ||
|
||
function fool(int256 b) private pure { | ||
b = b + 1; | ||
} | ||
|
||
// somfunc is `internal` | ||
function hof(function(int256) somfunc, int256 x) internal pure { | ||
x = x + 1; | ||
} | ||
|
||
function useHof() public { | ||
// `private` functions can be passed to functions expecting `internal` | ||
hof(fool, 10); | ||
a = 1 + 1; | ||
} | ||
} |
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,18 @@ | ||
contract A { | ||
uint256 internal a; | ||
|
||
function fool(int256 b) internal pure { | ||
b = b + 1; | ||
} | ||
|
||
// somfunc is `internal` | ||
function hof(function(int256) somfunc, int256 x) internal pure { | ||
x = x + 1; | ||
} | ||
|
||
function useHof() public { | ||
// `internal` functions can be passed to functions expecting `internal` | ||
hof(fool, 10); | ||
a = 1 + 1; | ||
} | ||
} |
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,17 @@ | ||
contract A { | ||
uint256 internal a; | ||
|
||
function fool(int256 b) public pure { | ||
b = b + 1; | ||
} | ||
|
||
function hof(function(int256) external somfunc, int256 x) internal pure { | ||
x = x + 1; | ||
} | ||
|
||
function useHof() public { | ||
// `public` functions can be passed to functions expecting `external`, using `this` | ||
hof(this.fool, 10); | ||
a = 1 + 1; | ||
} | ||
} |
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,17 @@ | ||
contract A { | ||
uint256 internal a; | ||
|
||
function fool(int256 b) external pure { | ||
b = b + 1; | ||
} | ||
|
||
function hof(function(int256) external somfunc, int256 x) internal pure { | ||
x = x + 1; | ||
} | ||
|
||
function useHof() public { | ||
// `external` functions can be passed to functions expecting `external`, using `this` | ||
hof(this.fool, 10); | ||
a = 1 + 1; | ||
} | ||
} |
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,40 @@ | ||
contract A { | ||
uint256 internal a; | ||
|
||
function fool(int256 b) internal pure { | ||
b = b + 1; | ||
} | ||
|
||
// `public` functions can have `external` function-type arguments | ||
function hof(function(int256) external somfunc, int256 x) public pure { | ||
x = x + 1; | ||
} | ||
|
||
// `private` functions can have `external` function-type arguments | ||
function hof2(function(int256) external somfunc, int256 x) private pure { | ||
x = x + 1; | ||
} | ||
|
||
// `private` functions can have `internal` function-type arguments | ||
function hof3(function(int256) internal somfunc, int256 x) private pure { | ||
x = x + 1; | ||
} | ||
|
||
// `internal` functions can have `internal` function-type arguments | ||
function hof4(function(int256) internal somfunc, int256 x) internal pure { | ||
x = x + 1; | ||
} | ||
|
||
// `internal` functions can have `external` function-type arguments | ||
function hof5(function(int256) external somfunc, int256 x) internal pure { | ||
x = x + 1; | ||
} | ||
|
||
// `external` functions can have `external` function-type arguments | ||
function hof6(function(int256) external somfunc, int256 x) external pure { | ||
x = x + 1; | ||
} | ||
|
||
// The other two combinations that fail (interal-external) and (internal-public) | ||
// are in `fails/hof_ko4.sol` and `fails/hof_ko5.sol` respectively | ||
} |
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,22 @@ | ||
contract A { | ||
uint256 internal a; | ||
|
||
function fool(int256 b) internal pure { | ||
b = b + 1; | ||
} | ||
|
||
// somfunc is `internal` | ||
function hof(function(int256) somfunc, int256 x) internal pure { | ||
x = x + 1; | ||
} | ||
|
||
function hofhof(function(function(int256), int256) somotherfunc, int256 x) internal { | ||
x = x + 1; | ||
} | ||
|
||
function useHof() public { | ||
hof(fool, 10); | ||
hofhof(hof, 10); | ||
a = 1 + 1; | ||
} | ||
} |