mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Rename .sig to .selector on function types
This commit is contained in:
parent
88946f9f03
commit
fd1f8ab38b
@ -1,7 +1,7 @@
|
|||||||
### 0.4.17 (unreleased)
|
### 0.4.17 (unreleased)
|
||||||
|
|
||||||
Features:
|
Features:
|
||||||
* Code Generator: Added ``.sig`` member on external function types to retrieve their signature.
|
* Code Generator: Added ``.selector`` member on external function types to retrieve their signature.
|
||||||
* Optimizer: Add new optimization step to remove unused ``JUMPDEST``s.
|
* Optimizer: Add new optimization step to remove unused ``JUMPDEST``s.
|
||||||
* Type Checker: Display helpful warning for unused function arguments/return parameters.
|
* Type Checker: Display helpful warning for unused function arguments/return parameters.
|
||||||
* Type Checker: Do not show the same error multiple times for events.
|
* Type Checker: Do not show the same error multiple times for events.
|
||||||
|
@ -2438,7 +2438,7 @@ MemberList::MemberMap FunctionType::nativeMembers(ContractDefinition const*) con
|
|||||||
MemberList::MemberMap members;
|
MemberList::MemberMap members;
|
||||||
if (m_kind == Kind::External)
|
if (m_kind == Kind::External)
|
||||||
members.push_back(MemberList::Member(
|
members.push_back(MemberList::Member(
|
||||||
"sig",
|
"selector",
|
||||||
make_shared<FixedBytesType>(4)
|
make_shared<FixedBytesType>(4)
|
||||||
));
|
));
|
||||||
if (m_kind != Kind::BareDelegateCall && m_kind != Kind::DelegateCall)
|
if (m_kind != Kind::BareDelegateCall && m_kind != Kind::DelegateCall)
|
||||||
|
@ -1068,7 +1068,7 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess)
|
|||||||
solAssert(false, "Invalid member access to integer");
|
solAssert(false, "Invalid member access to integer");
|
||||||
break;
|
break;
|
||||||
case Type::Category::Function:
|
case Type::Category::Function:
|
||||||
if (member == "sig")
|
if (member == "selector")
|
||||||
{
|
{
|
||||||
m_context << Instruction::SWAP1 << Instruction::POP;
|
m_context << Instruction::SWAP1 << Instruction::POP;
|
||||||
/// need to store store it as bytes4
|
/// need to store store it as bytes4
|
||||||
|
@ -10056,16 +10056,16 @@ BOOST_AUTO_TEST_CASE(function_types_sig)
|
|||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() returns (bytes4) {
|
function f() returns (bytes4) {
|
||||||
return this.f.sig;
|
return this.f.selector;
|
||||||
}
|
}
|
||||||
function g() returns (bytes4) {
|
function g() returns (bytes4) {
|
||||||
function () external returns (bytes4) fun = this.f;
|
function () external returns (bytes4) fun = this.f;
|
||||||
return fun.sig;
|
return fun.selector;
|
||||||
}
|
}
|
||||||
function h() returns (bytes4) {
|
function h() returns (bytes4) {
|
||||||
function () external returns (bytes4) fun = this.f;
|
function () external returns (bytes4) fun = this.f;
|
||||||
var funvar = fun;
|
var funvar = fun;
|
||||||
return funvar.sig;
|
return funvar.selector;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
@ -6290,34 +6290,34 @@ BOOST_AUTO_TEST_CASE(function_types_sig)
|
|||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() returns (bytes4) {
|
function f() returns (bytes4) {
|
||||||
return f.sig;
|
return f.selector;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
CHECK_ERROR(text, TypeError, "Member \"sig\" not found");
|
CHECK_ERROR(text, TypeError, "Member \"selector\" not found");
|
||||||
text = R"(
|
text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function g() internal {
|
function g() internal {
|
||||||
}
|
}
|
||||||
function f() returns (bytes4) {
|
function f() returns (bytes4) {
|
||||||
return g.sig;
|
return g.selector;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
CHECK_ERROR(text, TypeError, "Member \"sig\" not found");
|
CHECK_ERROR(text, TypeError, "Member \"selector\" not found");
|
||||||
text = R"(
|
text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() returns (bytes4) {
|
function f() returns (bytes4) {
|
||||||
function () g;
|
function () g;
|
||||||
return g.sig;
|
return g.selector;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
CHECK_ERROR(text, TypeError, "Member \"sig\" not found");
|
CHECK_ERROR(text, TypeError, "Member \"selector\" not found");
|
||||||
text = R"(
|
text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() returns (bytes4) {
|
function f() returns (bytes4) {
|
||||||
return this.f.sig;
|
return this.f.selector;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
@ -6325,7 +6325,7 @@ BOOST_AUTO_TEST_CASE(function_types_sig)
|
|||||||
text = R"(
|
text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() external returns (bytes4) {
|
function f() external returns (bytes4) {
|
||||||
return this.f.sig;
|
return this.f.selector;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
@ -6336,7 +6336,7 @@ BOOST_AUTO_TEST_CASE(function_types_sig)
|
|||||||
}
|
}
|
||||||
function f() external returns (bytes4) {
|
function f() external returns (bytes4) {
|
||||||
var g = this.h;
|
var g = this.h;
|
||||||
return g.sig;
|
return g.selector;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
@ -6347,7 +6347,7 @@ BOOST_AUTO_TEST_CASE(function_types_sig)
|
|||||||
}
|
}
|
||||||
function f() external returns (bytes4) {
|
function f() external returns (bytes4) {
|
||||||
function () external g = this.h;
|
function () external g = this.h;
|
||||||
return g.sig;
|
return g.selector;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
@ -6359,7 +6359,7 @@ BOOST_AUTO_TEST_CASE(function_types_sig)
|
|||||||
function f() external returns (bytes4) {
|
function f() external returns (bytes4) {
|
||||||
function () external g = this.h;
|
function () external g = this.h;
|
||||||
var i = g;
|
var i = g;
|
||||||
return i.sig;
|
return i.selector;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
Loading…
Reference in New Issue
Block a user