-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Add .selector member on function types #2473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6285,6 +6285,87 @@ BOOST_AUTO_TEST_CASE(modifiers_access_storage_pointer) | |
| CHECK_SUCCESS_NO_WARNINGS(text); | ||
| } | ||
|
|
||
| BOOST_AUTO_TEST_CASE(function_types_sig) | ||
| { | ||
| char const* text = R"( | ||
| contract C { | ||
| function f() returns (bytes4) { | ||
| return f.selector; | ||
| } | ||
| } | ||
| )"; | ||
| CHECK_ERROR(text, TypeError, "Member \"selector\" not found"); | ||
| text = R"( | ||
| contract C { | ||
| function g() internal { | ||
| } | ||
| function f() returns (bytes4) { | ||
| return g.selector; | ||
| } | ||
| } | ||
| )"; | ||
| CHECK_ERROR(text, TypeError, "Member \"selector\" not found"); | ||
| text = R"( | ||
| contract C { | ||
| function f() returns (bytes4) { | ||
| function () g; | ||
| return g.selector; | ||
| } | ||
| } | ||
| )"; | ||
| CHECK_ERROR(text, TypeError, "Member \"selector\" not found"); | ||
| text = R"( | ||
| contract C { | ||
| function f() returns (bytes4) { | ||
| return this.f.selector; | ||
| } | ||
| } | ||
| )"; | ||
| CHECK_SUCCESS_NO_WARNINGS(text); | ||
| text = R"( | ||
| contract C { | ||
| function f() external returns (bytes4) { | ||
| return this.f.selector; | ||
| } | ||
| } | ||
| )"; | ||
| CHECK_SUCCESS_NO_WARNINGS(text); | ||
| text = R"( | ||
| contract C { | ||
| function h() external { | ||
| } | ||
| function f() external returns (bytes4) { | ||
| var g = this.h; | ||
| return g.selector; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one is not detected yet.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @chriseth if you know a quick way to solve this, please do
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
| } | ||
| } | ||
| )"; | ||
| CHECK_SUCCESS_NO_WARNINGS(text); | ||
| text = R"( | ||
| contract C { | ||
| function h() external { | ||
| } | ||
| function f() external returns (bytes4) { | ||
| function () external g = this.h; | ||
| return g.selector; | ||
| } | ||
| } | ||
| )"; | ||
| CHECK_SUCCESS_NO_WARNINGS(text); | ||
| text = R"( | ||
| contract C { | ||
| function h() external { | ||
| } | ||
| function f() external returns (bytes4) { | ||
| function () external g = this.h; | ||
| var i = g; | ||
| return i.selector; | ||
| } | ||
| } | ||
| )"; | ||
| CHECK_SUCCESS_NO_WARNINGS(text); | ||
| } | ||
|
|
||
| BOOST_AUTO_TEST_CASE(using_this_in_constructor) | ||
| { | ||
| char const* text = R"( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works now, but not sure we are doing the right thing, since the function signature of this function type can be different depending on what function was assigned to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, but the correct type signature has to be there, since we also have to know it when we want to call the function. What are your worries?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind.