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

Makes local record field completion respects the fields sharing one single type signature #2439

Merged
merged 3 commits into from Dec 4, 2021

Conversation

konn
Copy link
Collaborator

@konn konn commented Dec 4, 2021

Currently, HLS generates wrong completion snippets for a record with some fields sharing the same type signature.
For example, consider the following:

data Foo = Foo { arg1, arg2 :: Int, arg3 :: Int, arg4 :: Bool }

Above, arg1, arg2 shares the same Int signature and this is a completely legitimate definition.
If this is defined in a local module, the current HLS generates the following record snippet for Foo, which lacks arg2:

Foo { arg1 = _arg1, arg3 = _arg3, arg4 = _arg4 }

The base cause of this seems as follows.
HLS handles record snippets for datatypes in a local module via parsed modules (findRecordCompl logic), especially from the RecCon constructor.
In RecCon, field information is stored as a list of ConDeclFields, which stores field label information in cd_fld_names field.
This cd_fld_names is a list of LFieldOccs, and it seems that this nested structure reflects the signature-sharing relation.
The current implementation in HLS, however, picks only the first element of cd_fld_names, resulting in the incomplete completion snippet.

This PR aims at fixing this issue by just returning lists as-is.

@konn konn changed the title Fixes local record field completion respects the fields sharing one single type signature. Makes local record field completion respects the fields sharing one single type signature Dec 4, 2021
@konn konn marked this pull request as ready for review December 4, 2021 06:46
@konn konn requested review from pepeiborra and Ailrun and removed request for pepeiborra December 4, 2021 06:46
@konn
Copy link
Collaborator Author

konn commented Dec 4, 2021

Oops, I somehow miss-clicked "remove request" link. I've just re-sent review request again.

Copy link
Member

@Ailrun Ailrun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jneira jneira merged commit 6c9d44f into haskell:master Dec 4, 2021
@konn konn deleted the shrothand-record-snippet-fix branch December 5, 2021 01:46
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.

None yet

3 participants