Repository navigation
Fix single-member enum literal subset checks - #5264
swaminimore wants to merge 1 commit into
Conversation
|
Hi @swaminimore! Thank you for your pull request and welcome to our community. Action RequiredIn 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. ProcessIn 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 If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
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.
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, unrelatedpyrefly/benches/micro.rsfile.AI assistance was used during investigation, implementation, and testing. The changes were reviewed and tested locally.