frangio / hardhat-exposed

Automatically expose internal Solidity functions for smart contract testing.
82 stars 13 forks source link

Function overflow clash #16

Open Amxx opened 1 year ago

Amxx commented 1 year ago

Reproducible example

In Test.sol:Foo

    //...
    struct Z {
        bool z;
    }

    struct Z2 {
        bool z;
    }

    function _testClash(S storage t) internal {}
    function _testClash(Z storage t) internal {}
    function _testClash(Z2 storage t) internal {}
    function _testClash(S memory t) internal {}
    function _testClash(Z memory t) internal {}
    function _testClash(Z2 memory t) internal {}
}

causes

TypeError: Function overload clash during conversion to external types for arguments.
  --> contracts-exposed/Test.sol:54:5:
   |
54 |     function $_testClash(Foo.Z2 calldata t) external {
   |     ^ (Relevant source part starts here and spans across multiple lines).

This is because the internal function use different types, but Z and Z2 have the same underlying type, cause the external version to have function selector clash.

Possible fix:

When constructing the clashingFunctions record, consider the resulting function selector, and not the internal type.