Compiler refuses to generate a getter if omitting struct fields would leave a nested struct empty
- Dominant language
- C++
- Stars
- 25.7k
- Forks
- 6.2k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 29
Description
## Description
The compiler refuses to generate a getter for a struct if omitting all dynamic array and/or mapping fields would leave it empty. There's however a case where this happens even if the outer struct would not actually be empty. That's the case when the fields are omitted only in a nested struct. Currently the compiler reports this as an error but I think that in this case it should just omit the whole nested struct instead.
## Steps to Reproduce
```solidity
contract C {
struct T { mapping(uint => uint) m; }
struct S { uint i; T t; }
S public x;
}
```
```
Error: Internal or recursive type is not allowed for public state variables.
--> test.sol:4:5:
|
4 | S public x;
| ^^^^^^^^^^
```
## Environment
- Compiler version: 0.8.10
Contributor guide
Research direction
Start by compiling the Solidity reproducer with compiler version 0.8.10 and trace the public getter generation for S, focusing on how omitted mapping fields in nested struct T are handled. Done means the compiler accepts S public x and omits the empty nested struct instead of reporting an internal or recursive type error.
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
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100