Skip to content

Support nested arrays #29

Description

@skonves

Context

The current IR models arrays using an isArray boolean on PrimitiveValue and ComplexValue. This approach limits expressiveness by preventing nested arrays (e.g. T[][]) and conflates container structure with leaf value definition. It also makes it difficult to clearly distinguish between constraints that apply to the array itself versus constraints that apply to its elements. As the IR evolves toward a more composable and machine-friendly representation, arrays should be modeled as first-class structural values rather than as modifiers on other value types.

Change

  • Remove isArray from PrimitiveValue and ComplexValue
  • Introduce a new ArrayValue definition
  • Add itemValue: MemberValue to ArrayValue
  • Add isNullable and isOptional to ArrayValue (applies to the array itself)
  • Include ArrayValue in the MemberValue union
  • Introduce array-specific rule definitions and attach them to ArrayValue.rules

Consequences

  • Enables modeling of nested arrays (e.g. T[][])
  • Clearly separates container structure from leaf value definition
  • Allows array-level rules to be structurally enforced (e.g. maxItems)
  • Improves consistency with future container types (e.g. tuples, maps)
  • Increases nesting depth of value definitions
  • Requires recursive traversal for consumers (e.g. finding leaf types)
  • Breaking change for existing parsers, rules, and generators

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions