Skip to content

enum/const: type inference #1529

@scop

Description

@scop

Description

When enum or const don't have a type set, ogen could infer the type by examining the values. Enums and consts implicitly constrain the type space, so type is redundant for them.

So for example if all values are strings, infer string type, if there are different types, only then use any, etc.

Also, when the type is not set for an enum or const, could see if the inference yields primitive types, and only when it does not, issue "non-primitive enum", otherwise let it pass.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions