Skip to content

Refactoring type constructor of data incorrectly renames the record fields too #4083

@Aster89

Description

@Aster89

Your environment

Which OS do you use? ArchLinux (up-to-date)
Which version of GHC do you use and how did you install it? 9.4.8, via GHCup
How is your project built (alternative: link to the project)? Irrelevant, I just open a new file

Which LSP client (editor/plugin) do you use? Vim(terminal) + YCM
Which version of HLS do you use and how did you install it? 2.5.0.0, via GHCup
Have you configured HLS in any way (especially: a hie.yaml file)? ... I think I haven't...

Steps to reproduce

  1. Create a one-line file with content data Foo = Bar { a :: !Int , b :: !Int }
  2. put the cursor try to refactor Bar to be Baz

Expected behaviour

The code should be become

data Foo = Bar { a :: !Int , b :: !Int }

Actual behaviour

But it becomes

data Foo = Baz { Baz :: !Int , Baz :: !Int }

Debug information

Is this the relevant piece?

2024-02-17 16:01:41,666 - DEBUG - TX: Sending message: b'Content-Length: 172\r\n\r\n{"id":2,"jsonrpc":"2.0","method":"textDocument/rename","params":{"newName":"Baz","position":{"character":13,"line":0},"textDocument":{"uri":"file:///home/enrico/uffa.hs"}}}'
2024-02-17 16:01:41,690 - DEBUG - RX: Received message: b'{"id":2,"jsonrpc":"2.0","result":{"documentChanges":[{"edits":[{"newText":"data Foo = Baz { Baz :: !Int , Baz :: !Int }","range":{"end":{"character":40,"line":0},"start":{"character":0,"line":0}}}],"textDocument":{"uri":"file:///home/enrico/uffa.hs","version":1}}]}}'
127.0.0.1 - - [17/Feb/2024 16:01:41] "POST /run_completer_command HTTP/1.1" 200 348
2024-02-17 16:01:41,693 - DEBUG - in-event <InotifyEvent: src_path=b'/home/enrico/.uffa.hs.swp', wd=1, mask=IN_MODIFY, cookie=0, name='.uffa.hs.swp'>
2024-02-17 16:01:41,713 - DEBUG - Event name: FileReadyToParse
2024-02-17 16:01:41,713 - INFO - Adding buffer identifiers for file: /home/enrico/uffa.hs
2024-02-17 16:01:41,714 - DEBUG - Refreshing file /home/enrico/uffa.hs: State is Open -> Open/action Change
2024-02-17 16:01:41,714 - DEBUG - TX: Sending notification: b'Content-Length: 204\r\n\r\n{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"text":"data Foo = Baz { Baz :: !Int , Baz :: !Int }\\n"}],"textDocument":{"uri":"file:///home/enrico/uffa.hs","version":2}}}'
127.0.0.1 - - [17/Feb/2024 16:01:41] "POST /event_notification HTTP/1.1" 200 2
2024-02-17 16:01:41,717 - DEBUG - RX: Received message: b'{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"message":"parse error on input \xe2\x80\x98Baz\xe2\x80\x99","range":{"end":{"character":20,"line":0},"start":{"character":17,"line":0}},"severity":1,"source":"parser"}],"uri":"file:///home/enrico/uffa.hs","version":2}}'

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: needs triagetype: 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

    Development

    No branches or pull requests

    Issue actions