ethereum / solidity

Solidity, the Smart Contract Programming Language
https://soliditylang.org
GNU General Public License v3.0
23.14k stars 5.74k forks source link

`encodeCall()` causes compile failure for overloaded functions like ERC721's `safeTransferFrom` #13815

Closed dnlchong closed 1 year ago

dnlchong commented 1 year ago

Description

encodeCall fails when using a function selector of an overloaded function.

Environment

Steps to Reproduce

Attempt to compile the following code. The error occurs because safeTransferFrom is an overloaded function.

import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; // OpenZeppelin v4.6.0

(bool transferSuccess, bytes memory transferResult) = address(_erc721Address).call(
    abi.encodeCall(IERC721(_erc721Address).safeTransferFrom, (_ownerAddress, vaultAddress, _erc721Id))
);

// Error: Member "safeTransferFrom" not unique after argument-dependent lookup in contract IERC721

I've looked around but could not find this issue mentioned in the repo. I can start working on a PR if the issue looks valid.

dnlchong commented 1 year ago

related https://github.com/ethereum/solidity/issues/13813 ?

cameel commented 1 year ago

13813 is something entirely different (it's only about how the error message looks like). But we do have an issue for this exact issue (#3556) so closing as duplicate.