argotorg/solidity

Should private functions really clash ?

開放

#11,889 建立於 2021年9月3日

 (45 則留言) (6 個反應) (0 位負責人)C++ (6,109 個分叉)batch import
bounty worthy :moneybag:help wantedlow effortlow impactnice to have

倉庫指標

星標
 (25,634 顆星)
PR 合併指標
 (平均合併 8天 8小時) (30 天內合併 30 個 PR)

描述

Let consider the following code:

contract A {
    function __myPrivateFunction() private {
        // Does something usefull
    }
    
    function callA() public {
        __myPrivateFunction();
    }
}

contract B {
    function __myPrivateFunction() private {
        // Does something usefull
    }
    
    function callB() public {
        __myPrivateFunction();
    }
}

contract AB is A, B {}

What I am expecting

implementation of __myPrivateFunction are private, and they only make sense in the context of the contract that they are part of (A and B). They are not accessible from AB, so it is not like if a call from a function within AB wouldn't be resolvable.

IMO, this should compile, possibly with a warning, but not with an error.

What happens

I get an error:

TypeError: Derived contract must override function "__myPrivateFunction". Two or more base classes define function with same name and parameter types.

Question/Request

Is that behaviour wanted? needed? Whould it be possible to accept this kind of ghost-conflicts?

貢獻者指南