Support inheritance combining constants
- Dominant language
- C++
- Stars
- 25.7k
- Forks
- 6.2k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 29
Description
## Abstract
I want to be able to do the following inheritance structure:
```solidity
// SPDX-License-Identifier: MIT-1.0
pragma solidity ^0.8.28;
interface A {
function FOO() external view returns (uint256);
function bar() external;
}
abstract contract B {
uint256 public constant FOO = 4;
}
contract C is A, B {
function bar() external {
//(...)
}
//(...)
}
```
Compiler currently does not like it:
```
TypeError: Derived contract must override function "FOO". Two or more base classes define function with same name and parameter types. Since one of the bases defines a public state variable which cannot be overridden, you have to change the inheritance layout or the names of the functions.
--> Test.sol:12:1:
|
12 | contract C is A, B{
| ^ (Relevant source part starts here and spans across multiple lines).
Note: Definition in "A":
--> Test.sol:5:5:
|
5 | function FOO() external view returns (uint256);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Note: Definition in "B":
--> Test.sol:9:5:
|
9 | uint256 public constant FOO = 4;
|
```
Contributor guide
Research direction
Start by compiling the minimal Solidity inheritance example in the issue and confirm the current override error. Trace the compiler's handling of interface functions and public constant getters; done means the shown A, B, and C hierarchy compiles without requiring an explicit override while preserving the expected FOO getter behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, solidity
- Domain
- blockchain, compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100