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

fix: generate __is-aware code for is on unions #819

Merged
merged 1 commit into from
Oct 16, 2024
Merged

fix: generate __is-aware code for is on unions #819

merged 1 commit into from
Oct 16, 2024

Conversation

hishamhm
Copy link
Member

This expands an is applied to a union (even in behind an alias) into a chain of or tests with individual is checks on the types of the union. If the individual entries have __is metamethods, expands their code as well.

This implementation is not recursive (i.e. it does not handle unions of unions), but it is a major improvement over the previous behavior.

Fixes #742.

Copy link

Teal Playground URL: https://819--teal-playground-preview.netlify.app

This expands an `is` applied to a union (even in behind an alias)
into a chain of `or` tests with individual `is` checks on the
types of the union. If the individual entries have __is metamethods,
expands their code as well.

This implementation is not recursive (i.e. it does not handle
unions of unions), but it is a major improvement over the previous
behavior.

Fixes #742.
@hishamhm hishamhm merged commit e240869 into master Oct 16, 2024
8 checks passed
@hishamhm hishamhm deleted the fix-742 branch October 16, 2024 14:11
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.

Type guard doesn't work properly with unions
1 participant