Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposed new syntax to support custom implementation of union id #59

Closed
driftluo opened this issue Sep 14, 2022 · 0 comments · Fixed by #65
Closed

Proposed new syntax to support custom implementation of union id #59

driftluo opened this issue Sep 14, 2022 · 0 comments · Fixed by #65

Comments

@driftluo
Copy link
Collaborator

Currently, the scheme of the union type is:

union DiscoveryPayload {
    A,
    B,
    C,
    D,
}

The parser implicitly sets the id of the union child to increment from 0. The scheme above can be translated as:

union DiscoveryPayload {
    A = 0,
    B = 1,
    C = 2,
    D = 3,
}

Unfortunately, the current union syntax does not support customizing this id, with the consequence that the generated code cannot be deleted if the preceding child is disambiguated because the id is automatically generated by the parser

From the perspective of real projects, it is relatively common for union subclauses to be deprecated, and it is good for users to support the new syntax for customizing ids

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 a pull request may close this issue.

1 participant