Merge pull request #12779 from nishant-sachdeva/distinguish_different_types_in_error_messages_from_abiEncodecall

Error messages from abi encodecall are giving more details about the types of the involved variables
This commit is contained in:
Nishant Sachdeva 2022-03-11 16:50:45 +05:30 committed by GitHub
commit 1827df8a2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 52 additions and 3 deletions

View File

@ -2204,9 +2204,9 @@ void TypeChecker::typeCheckABIEncodeCallFunction(FunctionCall const& _functionCa
"Cannot implicitly convert component at position " +
to_string(i) +
" from \"" +
argType.canonicalName() +
argType.toString() +
"\" to \"" +
functionPointerType->parameterTypes()[i]->canonicalName() +
functionPointerType->parameterTypes()[i]->toString() +
"\"" +
(result.message().empty() ? "." : ": " + result.message())
);

View File

@ -0,0 +1,11 @@
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".

View File

@ -0,0 +1,13 @@
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".

View File

@ -0,0 +1,13 @@
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)".

View File

@ -0,0 +1,12 @@
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".

View File

@ -24,4 +24,4 @@ contract C {
// TypeError 7788: (382-408): Expected 1 instead of 0 components for the tuple parameter.
// TypeError 6219: (489-511): Expected two arguments: a function pointer followed by a tuple.
// TypeError 7515: (597-628): Expected a tuple with 2 components instead of a single non-tuple parameter.
// TypeError 5407: (621-627): Cannot implicitly convert component at position 0 from "uint8[2]" to "int256".
// TypeError 5407: (621-627): Cannot implicitly convert component at position 0 from "uint8[2] memory" to "int256".