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

GenType: fix issue with @as("0") and other numbers. #6487

Merged
merged 2 commits into from
Nov 21, 2023

Conversation

cristianoc
Copy link
Collaborator

There is some special code in the type emitter to take care of poly variants of the form e.g. #0, which is represented internally as the string "0". This conflicts with normal variants annotated with @as("0") and such.

This PR resolves the case of numeric poly variants early on, and removes the special casing in the code emitter.

Fixes #6486

There is some special code in the type emitter to take care of poly variants of the form e.g. `#0`, which is represented internally as the string "0".
This conflicts with normal variants annotated with `@as("0")` and such.

This PR resolves the case of numeric poly variants early on, and removes the special casing in the code emitter.

Fixes #6486
type t = Array(array<int>) | Record({x: int}) | Function((. int) => int)

@genType
type tabIndex = | @as("0") Activity | @as("1") UserKeyword
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a test for @as(0) too?

Copy link
Collaborator

@zth zth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good one.

@cristianoc cristianoc merged commit 232cf78 into master Nov 21, 2023
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.

bug(genType): @genType @as("0") generates type 0 not "0"
2 participants