Skip to content

Code action "expand positional record" produces invalid code. #4564

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

Open
AndreasPK opened this issue Apr 17, 2025 · 3 comments · May be fixed by #4586
Open

Code action "expand positional record" produces invalid code. #4564

AndreasPK opened this issue Apr 17, 2025 · 3 comments · May be fixed by #4586
Assignees
Labels
component: hls-explicit-record-fields-plugin Issues related to the hls-explicit-record-fields-plugin type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@AndreasPK
Copy link

AndreasPK commented Apr 17, 2025

Your environment

HLS version is Version 2.9.0.1 x86_64 ghc-9.10.1 under VSCode/Linux

Steps to reproduce

See below under actual behaviour.

Expected behaviour

Code actions on valid code should result in valid code.

Actual behaviour

Given this snippet:

data T = MkT { fa :: Int, fb :: Char}

foo :: Int -> Char -> T
foo x = (MkT x)

HLS suggests replacing (MkT x) with MkT { fa = x }.

However this fails to typecheck. As the first expression has type Char -> T while the later has type T

@AndreasPK AndreasPK added status: needs triage type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. labels Apr 17, 2025
@fendor fendor added component: hls-explicit-record-fields-plugin Issues related to the hls-explicit-record-fields-plugin and removed status: needs triage labels Apr 18, 2025
@fendor
Copy link
Collaborator

fendor commented Apr 18, 2025

@ozkutuk Afaict, this looks like it is related to the hls-explicit-record-fields-plugin.
Perhaps you have an idea about what's up here?

@AndreasPK
Copy link
Author

Afaict, this looks like it is related to the hls-explicit-record-fields-plugin.

Disabling Explicit Fields inlays and actions at least hides the broken suggests 👍

@ozkutuk
Copy link
Collaborator

ozkutuk commented Apr 18, 2025

I am a bit surprised that this is related to the hls-explicit-record-fields-plugin, since IIRC that plugin should only pick up records constructed with the record literal syntax. Though I think the plugin was extended a bit since my initial implementation to provide support for inlay hints, and that might have something to do with it. I'll refamiliarize myself with the current code of the plugin and take a look into this issue afterwards when I can carve up the time to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: hls-explicit-record-fields-plugin Issues related to the hls-explicit-record-fields-plugin type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
3 participants