Skip to content

2.0: add ExpectedTable variant so table accessors return WrongType #28

Description

@tylerbutler

Summary

Adding an ExpectedTable variant to ExpectedType so table-shaped accessors (e.g. the table_keys helper proposed in #23) can return a precise WrongType error when a path resolves to a non-table value.

Why this is breaking (and therefore 2.0)

ExpectedType documents its variants as part of the stable public API:

Variants are part of the stable public API. Adding, removing, or renaming a variant is treated as a breaking change.

So introducing ExpectedTable is a major-version change. Until then, accessors like table_keys (#23) must work around the gap — either reusing an existing ExpectedType value (inaccurate), collapsing the non-table case into KeyNotFound (lossy), or returning a bare List(String) and sidestepping GetError entirely.

Proposed change

pub type ExpectedType {
  ExpectedString
  ExpectedInt
  ExpectedBool
  ExpectedFloat
  ExpectedDate
  ExpectedTime
  ExpectedDateTime
  ExpectedTable   // new
}

This lets table_keys (and any future table-shaped accessor) return:

  • missing key -> Error(KeyNotFound(path))
  • present but not a table -> Error(WrongType(path, ExpectedTable))

matching the existing get_* family's error style.

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions