mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #2473 from ethereum/functiontype-sig
Add .selector member on function types
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
)";
|
||||
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"(
|
||||
|
||||
Reference in New Issue
Block a user