typeCheckAbiEncodeCallFunction should type check the arguments on functionPointerType->asExternallyCallableFunction instead of teh plain function type

This commit is contained in:
nishant-sachdeva
2022-03-24 18:53:46 +05:30
parent b08190c284
commit 4c6066bfad
9 changed files with 90 additions and 73 deletions
@@ -0,0 +1,35 @@
interface testInterface {
function C(function (string memory) external) external;
function D(string calldata) external;
function E(string memory) external;
function F(address) external;
}
contract testContract {
function g(string calldata) external {}
function h(string memory) external {}
function i(string calldata str) external {
this.h(str);
this.g(str);
}
function j(string memory str) external {
this.h(str);
this.g(str);
}
function k(string memory str) external pure {
abi.encodeCall(testInterface.D, (str));
}
string s;
function main() external view {
abi.encodeCall(testInterface.C, (this.g));
abi.encodeCall(testInterface.C, (this.h));
abi.encodeCall(testInterface.D, (s));
abi.encodeCall(testInterface.E, (s));
abi.encodeCall(testInterface.F, (payable(address(0))));
abi.encodeCall(this.i, (s));
abi.encodeCall(this.j, (s));
}
}
// ----
// Warning 6133: (860-914): Statement has no effect.
@@ -0,0 +1,11 @@
interface testInterface {
function A(address payable) external;
}
contract testContract {
function main() external view {
abi.encodeCall(testInterface.A, (address(0)));
}
}
// ----
// TypeError 5407: (171-183): Cannot implicitly convert component at position 0 from "address" to "address payable".
@@ -0,0 +1,16 @@
interface testInterface {
function B(function (string calldata) external) external;
}
contract testContract {
function g(string calldata) external {}
function h(string memory) external {}
function main() external view {
abi.encodeCall(testInterface.B, (this.g));
abi.encodeCall(testInterface.B, (this.h));
}
}
// ----
// TypeError 5407: (278-286): Cannot implicitly convert component at position 0 from "function (string memory) external" to "function (string calldata) external".
// TypeError 5407: (329-337): Cannot implicitly convert component at position 0 from "function (string memory) external" to "function (string calldata) external".
@@ -1,11 +0,0 @@
interface I {
function f(address payable) external;
}
contract C {
function main() external view {
abi.encodeCall(I.f, (address(0)));
}
}
// ----
// TypeError 5407: (136-148): Cannot implicitly convert component at position 0 from "address" to "address payable".
@@ -1,13 +0,0 @@
interface I {
function f(function (string calldata) external) external;
}
contract C {
function g(string calldata) external {}
function main() external view {
abi.encodeCall(I.f, (this.g));
}
}
// ----
// TypeError 5407: (201-209): Cannot implicitly convert component at position 0 from "function (string memory) external" to "function (string calldata) external".
@@ -1,13 +0,0 @@
interface I {
function f(function (string calldata) external view returns (uint)) external;
}
contract C {
function g(string memory) external {}
function main() external view {
abi.encodeCall(I.f, (this.g));
}
}
// ----
// TypeError 5407: (219-227): Cannot implicitly convert component at position 0 from "function (string memory) external" to "function (string calldata) view external returns (uint256)".
@@ -1,12 +0,0 @@
interface I {
function f(string calldata) external;
}
contract C {
string s;
function main() external view {
abi.encodeCall(I.f, (s));
}
}
// ----
// TypeError 5407: (150-153): Cannot implicitly convert component at position 0 from "string storage ref" to "string calldata".