mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #5351 from ethereum/functionTypeConversion
Relax type equality requirement of function types during conversion in code generation.
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
contract C {
|
||||
function h() external {
|
||||
}
|
||||
function f() view external returns (bytes4) {
|
||||
function () payable external g = this.h;
|
||||
return g.selector;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (105-144): Type function () external is not implicitly convertible to expected type function () payable external.
|
||||
@@ -0,0 +1,10 @@
|
||||
contract C {
|
||||
function h() external {
|
||||
}
|
||||
function f() view external returns (bytes4) {
|
||||
function () pure external g = this.h;
|
||||
return g.selector;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (105-141): Type function () external is not implicitly convertible to expected type function () pure external.
|
||||
@@ -0,0 +1,10 @@
|
||||
contract C {
|
||||
function h() external {
|
||||
}
|
||||
function f() view external returns (bytes4) {
|
||||
function () view external g = this.h;
|
||||
return g.selector;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (105-141): Type function () external is not implicitly convertible to expected type function () view external.
|
||||
@@ -0,0 +1,8 @@
|
||||
contract C {
|
||||
function h() payable external {
|
||||
}
|
||||
function f() view external returns (bytes4) {
|
||||
function () external g = this.h;
|
||||
return g.selector;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
contract C {
|
||||
function h() payable external {
|
||||
}
|
||||
function f() view external returns (bytes4) {
|
||||
function () pure external g = this.h;
|
||||
return g.selector;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (113-149): Type function () payable external is not implicitly convertible to expected type function () pure external.
|
||||
@@ -0,0 +1,10 @@
|
||||
contract C {
|
||||
function h() payable external {
|
||||
}
|
||||
function f() view external returns (bytes4) {
|
||||
function () view external g = this.h;
|
||||
return g.selector;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (113-149): Type function () payable external is not implicitly convertible to expected type function () view external.
|
||||
@@ -0,0 +1,8 @@
|
||||
contract C {
|
||||
function h() pure external {
|
||||
}
|
||||
function f() view external returns (bytes4) {
|
||||
function () external g = this.h;
|
||||
return g.selector;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
contract C {
|
||||
function h() pure external {
|
||||
}
|
||||
function f() view external returns (bytes4) {
|
||||
function () payable external g = this.h;
|
||||
return g.selector;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (110-149): Type function () pure external is not implicitly convertible to expected type function () payable external.
|
||||
@@ -0,0 +1,8 @@
|
||||
contract C {
|
||||
function h() pure external {
|
||||
}
|
||||
function f() view external returns (bytes4) {
|
||||
function () view external g = this.h;
|
||||
return g.selector;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
contract C {
|
||||
int dummy;
|
||||
function h_nonpayable() external { dummy = 1; }
|
||||
function h_payable() payable external {}
|
||||
function h_view() view external { dummy; }
|
||||
function h_pure() pure external {}
|
||||
function f() view external {
|
||||
function () external g_nonpayable = this.h_nonpayable; g_nonpayable;
|
||||
function () payable external g_payable = this.h_payable; g_payable;
|
||||
function () view external g_view = this.h_view; g_view;
|
||||
function () pure external g_pure = this.h_pure; g_pure;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
@@ -0,0 +1,10 @@
|
||||
contract C {
|
||||
int dummy;
|
||||
function h() view external {
|
||||
dummy;
|
||||
}
|
||||
function f() view external returns (bytes4) {
|
||||
function () external g = this.h;
|
||||
return g.selector;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
contract C {
|
||||
function h() view external {
|
||||
}
|
||||
function f() view external returns (bytes4) {
|
||||
function () payable external g = this.h;
|
||||
return g.selector;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (110-149): Type function () view external is not implicitly convertible to expected type function () payable external.
|
||||
@@ -0,0 +1,10 @@
|
||||
contract C {
|
||||
function h() view external {
|
||||
}
|
||||
function f() view external returns (bytes4) {
|
||||
function () pure external g = this.h;
|
||||
return g.selector;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (110-146): Type function () view external is not implicitly convertible to expected type function () pure external.
|
||||
Reference in New Issue
Block a user