Skip to content

Support integer Struct tags - #135

Merged
jcrist merged 1 commit into
mainfrom
struct-int-tags
Jul 1, 2022
Merged

Support integer Struct tags#135
jcrist merged 1 commit into
mainfrom
struct-int-tags

Conversation

@jcrist

@jcrist jcrist commented Jul 1, 2022

Copy link
Copy Markdown
Member

Previously tagged unions only supported str tag values. We now also
support int tag values, with a few caveats:

  • A single Union of Struct types cannot mix both int and str tag
    types.
  • Integer tag values currently only support values that fit in an
    int64 (-2**63 <= tag <= 2**63 - 1). This restriction has also been added
    to IntEnum and integer Literal types (previously these supported up
    to a uint64). This restriction makes the implementation easier, but
    can be removed if needed in the future. For now a NotImplementedError
    is raised if the user attempts to use out-of-range integer values,
    pointing them to raise an issue on GitHub if they need the feature.

Fixes #134.

Previously tagged unions only supported `str` tag values. We now also
support `int` tag values, with a few caveats:

- A single `Union` of `Struct` types cannot mix both `int` and `str` tag
types.
- Integer `tag` values currently only support values that fit in an
int64 (-2**63 <= tag <= 2**63 - 1). This restriction has also been added
to `IntEnum` and integer `Literal` types (previously these supported up
to a `uint64`). This restriction makes the implementation easier, but
can be removed if needed in the future. For now a `NotImplementedError`
is raised if the user attempts to use out-of-range integer values,
pointing them to raise an issue on GitHub if they need the feature.
@jcrist jcrist mentioned this pull request Jul 1, 2022
@jcrist
jcrist merged commit 0e83653 into main Jul 1, 2022
@jcrist
jcrist deleted the struct-int-tags branch July 1, 2022 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Non-string tag values

1 participant