Skip to content

Compiler refuses to generate a getter if omitting struct fields would leave a nested struct empty #12385

Open
@cameel

Description

@cameel

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛high effortA lot to implement but still doable by a single person. The task is large or difficult.medium impactDefault level of impactmust haveSomething we consider an essential part of Solidity 1.0.should compile without errorError is reported even though it shouldn't. Source is fine.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions