Skip to content

Fix single-member enum literal subset checks - #5264

Open
swaminimore wants to merge 1 commit into
facebook:mainfrom
swaminimore:fix/5191-single-member-enum-literal
Open

swaminimore wants to merge 1 commit into
facebook:mainfrom
swaminimore:fix/5191-single-member-enum-literal

Conversation

@swaminimore

Copy link
Copy Markdown

Summary

Fixes #5191

When a union containing a literal of a single-member enum is normalized to the enum class, Pyrefly can incorrectly reject the resulting type against a generic type alias containing that enum literal.

This change updates subset checking to accept the enum class as compatible with its literal member when both refer to the same enum and that enum has exactly one member. Multi-member enums remain subject to the existing compatibility checks.

Regression tests cover the generic type-alias case, direct function arguments, inline enum-literal unions, and compatibility boundaries for multi-member enums.

  • I am a human, and I fully understand the code I am submitting.

Test Plan

  • cargo test -p pyrefly - passed (9,109 tests passed, 3 ignored).
  • cargo fmt --check - passed, with warnings for nightly-only formatting options.
  • git diff --check - passed.
  • python3 test.py --no-test --no-tensor-shapes --no-conformance --no-jsonschema - passed.
  • cargo clippy -p pyrefly --all-targets - completed with one warning in the existing, unrelated pyrefly/benches/micro.rs file.

AI assistance was used during investigation, implementation, and testing. The changes were reviewed and tested locally.

@meta-cla

meta-cla Bot commented Oct 18, 2026

Copy link
Copy Markdown

Hi @swaminimore!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla

meta-cla Bot commented Oct 18, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Literal[Enum.MEMBER] in a union is normalized to the enum class, then rejected against a generic TypeAlias containing the same literal

2 participants