Only expand positional records if the DataCon application is fully saturated#4586
Merged
Conversation
fendor
approved these changes
May 10, 2025
fendor
left a comment
Collaborator
There was a problem hiding this comment.
LGTM, thanks for taking care of this!
Comment on lines
+181
to
+182
| RecordInfoApp _ (RecordAppExpr Unsaturated _ _) -> False | ||
| _ -> True |
Collaborator
There was a problem hiding this comment.
Since it is only two cases, maybe we should be exhaustive?
Collaborator
Author
There was a problem hiding this comment.
Maybe I misunderstood you, but I can't see how it is only two cases. This is what I come up with if I try to make this fully exhaustive:
isConvertible :: RecordInfo -> Bool
isConvertible = \case
RecordInfoApp _ (RecordAppExpr Unsaturated _ _) -> False
RecordInfoApp _ (RecordAppExpr Saturated _ _) -> True
RecordInfoPat {} -> True
RecordInfoCon {} -> TrueI personally find this a bit too verbose, but if that's the style the codebase favors, I would be happy to change.
Collaborator
There was a problem hiding this comment.
It is just my preference, but since you are maintaining the plugin right now, your opinion matters more than mine in style preferences.
Also, thought it would be two, not 4, so yeah, that's more verbose than anticipated.
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.
Fixes #4564.
"Positional record expansion" only makes sense if the constructor application has all the required arguments provided, otherwise invalid code is generated as demonstrated in the linked issue. This PR augments the collected records with "saturation" information, so that unsatured applications can be filtered out during the code action generation.
(cc: @jetjinser, do you mind taking a look into this, as you were the author of #4447)