fix improve enum error suggestion #3128#3145
Open
asukaminato0721 wants to merge 2 commits intofacebook:mainfrom
Open
fix improve enum error suggestion #3128#3145asukaminato0721 wants to merge 2 commits intofacebook:mainfrom
asukaminato0721 wants to merge 2 commits intofacebook:mainfrom
Conversation
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
Adds enum-member “did you mean …” suggestions to call-argument type mismatch diagnostics when a provided literal exactly matches an enum’s underlying value (fixing #3128).
Changes:
- Add enum-value → enum-member suggestion helper in enum handling code.
- Extend call-argument type-check error reporting to append an enum-member suggestion line when applicable.
- Add a regression test covering
StrEnumargument mismatch suggestions.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
pyrefly/lib/test/enums.rs |
Adds regression test asserting the new call-argument suggestion text for StrEnum. |
pyrefly/lib/alt/class/enums.rs |
Implements logic to map a raw literal type to a unique enum member suggestion. |
pyrefly/lib/alt/answers_solver.rs |
Injects enum-member suggestion lines into call-argument diagnostics during check_type failures. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
rchen152
requested changes
Apr 15, 2026
Contributor
rchen152
left a comment
There was a problem hiding this comment.
The Copilot feedback looks legitimate here - specifically, the concerns about union handling and code duplication.
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #3128
The change teaches call-argument diagnostics to suggest an enum member when the provided raw literal exactly matches a single expected enum value.
Test Plan
add test