Overhaul Inheritance and Override Logic
- Dominant language
- C++
- Stars
- 25.7k
- Forks
- 6.2k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 21
Description
https://github.com/ethereum/solidity/issues/12615 reported a serious error in our override logic.
While https://github.com/ethereum/solidity/pull/12616 fixes the issue, we realized that our strict override logic has some counterintuitive implications, namely https://github.com/ethereum/solidity/pull/12616#discussion_r797992050 and https://github.com/ethereum/solidity/pull/12616#discussion_r797985635.
So we intend to relax our override requirements to avoid cases like that.
In particular, we want to have a specification with the following property:
- Each direct base of a contract can contribute at most one base function to the override requirements of a function.
In particular consider the following situation:
```
interface I { function f() external; }
contract A is I { function f() external {} }
contract B is I { }
contract C is A, B {
// no override is required here!
}
contract D is C {
// The following *should* be valid, but currently fails and requires "override(I, A)".
function f() external override // more specifically "override(A)"
{
}
}
```
Our current plan is to relax the override requirements, s.t. ``D`` in the example becomes valid.
However, this is breaking (since currently specifying more bases than required is an error).
So more specifically, we want to do this change while allowing additional bases (with a warning) in 0.8, while those additional bases will become an error only in 0.8.
So this issue has two parts:
- [ ] Relax the override requirements while allowing the bases that were previously required with a warning (non-breaking).
- [ ] Disallow the additional bases we warned about in the next breaking release (breaking).
Contributor guide
Research direction
Start with issue #12615 and pull request #12616, including the linked discussions, to understand the current override behavior and the proposed relaxation. Trace the compiler's inheritance and override handling and its regression coverage, although this issue names no file or test paths. Done means implementing both release phases: warnings for previously required bases in 0.8 and errors for those additional bases in the next breaking release.
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
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100