Skip to content

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

@AndreasPK

Description

@AndreasPK

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

Activity

added
type: bugSomething isn't right: doesn't work as intended, documentation is missing/outdated, etc..
on Apr 17, 2025
fendor

fendor commented on Apr 18, 2025

@fendor
Collaborator

@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

AndreasPK commented on Apr 18, 2025

@AndreasPK
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

ozkutuk commented on Apr 18, 2025

@ozkutuk
Collaborator

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.

self-assigned this
on May 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

component: hls-explicit-record-fields-pluginIssues related to the hls-explicit-record-fields-plugintype: bugSomething isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @AndreasPK@ozkutuk@fendor

    Issue actions

      Code action "expand positional record" produces invalid code. · Issue #4564 · haskell/haskell-language-server