argotorg / argotorg/solidity

Should private functions really clash ?

Open
#11,889 45 comments 6 reactions 0 assignees View on GitHub
bounty worthy :moneybag: help wanted low effort low impact nice to have
Dominant language
C++
Stars
25.7k
Forks
6.2k
Avg merge
1d 11h
Merged PRs (30d)
21

Description

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?

Contributor guide

Open the contributing guide

Research direction

Reproduce the A/B/AB inheritance example with the Solidity compiler and inspect the duplicate-function diagnostic. Evaluate the requested behavior—accepting private functions with the same name and signature, possibly with a warning—and determine the language-semantics implications before defining completion criteria.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, solidity
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.