Inherited enums, structs and UDVTs are accessible via derived contract name only in variable definitions
- Dominant language
- C++
- Stars
- 25.7k
- Forks
- 6.2k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 21
Description
## Description
The values of an enum type get inaccessible when inheriting the type into another interface/contract and referring to the type there.
## Environment
- Compiler version: 0.8.25
## Steps to Reproduce
This program compiles:
```solidity
interface X {
enum E {a,b,c}
}
interface Y is X { }
contract c {
function f (Y.E e) public pure returns(bool) {
return e == X.E.a;
}
}
```
When replacing `X.E.a` by `Y.E.a`, the compiler gives the error
```
Member "E" not found or not visible after argument-dependent lookup in type(contract Y).
```
Note that the parameter type `Y.E` does not raise an error, only the expression `Y.E.a` does. At a minimum, the error message is misleading. But actually, I would have expected `Y.E.a` to work as well, since `Y.E` is known. It would be useful if one could use `Y` as a replacement of `X`, without the need to know that `Y.E` has been actually defined in an inherited interface.
Contributor guide
Research direction
Start by compiling the Solidity 0.8.25 reproduction from the issue and compare the accepted Y.E parameter type with the failing Y.E.a expression. Trace the compiler's inherited enum, struct, and UDVT lookup, then verify that the intended aliasing behavior or a non-misleading diagnostic is covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, solidity
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100