Nested dynamic arrays are not omitted from getters
- Dominant language
- C++
- Stars
- 25.7k
- Forks
- 6.2k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 21
Description
## Description
This is what the docs say about omitting return variables from [getters](https://docs.soliditylang.org/en/latest/contracts.html#getter-functions) generated by the compiler:
> The mapping and arrays (with the exception of byte arrays) in the struct are omitted because there is no good way to select individual struct members or provide a key for the mapping:
Turns out that this does not apply to dynamic arrays nested inside structs. I'm not sure if it's intentional or not. If it's not, it needs to be fixed. If it is, it should be documented.
## Steps to Reproduce
Nested mappings are omitted:
```solidity
contract C {
struct T { mapping(uint => uint) m; }
struct S { T t; }
S public x;
}
```
```
Error: Internal or recursive type is not allowed for public state variables.
--> test2.sol:4:5:
|
4 | S public x;
| ^^^^^^^^^^
```
But nested dynamic arrays are not. This compiles find and does return the whole array (tested in Remix):
```solidity
contract C {
struct T { uint[] u; }
struct S { T t; }
S public x;
}
```
## Environment
- Compiler version: 0.8.10
Contributor guide
Research direction
Start by reproducing the nested-mapping and nested-dynamic-array examples with Solidity compiler version 0.8.10, then read the linked getter documentation and locate the compiler tests or implementation that determine which struct members getters expose. Done means the behavior is intentionally aligned with the documentation, either through a compiler change with regression coverage or through clarified documentation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- solidity
- Domain
- blockchain, compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100