haskell / haskell/haskell-language-server

Renaming a variable that gets used in a record wild card will rename the field of that record.

Open
#5,032 0 comments 1 reaction 0 assignees View on GitHub
component: hls-rename-plugin type: bug
Dominant language
Haskell
Stars
3k
Forks
455
Avg merge
4d 3h
Merged PRs (30d)
12

Description

### Your environment

Which OS do you use? nixos

Which version of GHC do you use and how did you install it? 9.12.3, nixpkgs

How is your project built (alternative: link to the project)? single module

Which LSP client (editor/plugin) do you use? n/a

Which version of HLS do you use and how did you install it? 2.13.0.0, nixpkgs

Have you configured HLS in any way (especially: a `hie.yaml` file)?

### Steps to reproduce

```haskell
{-# LANGUAGE RecordWildCards #-}
module Rename where

data Foo = MkFoo {foo :: Int}

y = foo (MkFoo 2)

x = MkFoo {..}
where
foo = 3
```

when renaming `foo` to `bar` in the `where` clause on the last line, we get:
```haskell
{-# LANGUAGE RecordWildCards #-}
module Rename where

data Foo = MkFoo {bar :: Int}

y = bar (MkFoo 2)

x = MkFoo {..}
where
bar = 3
```
which is a valid program but arguably not what the user might have intended (definitely not what I intended... ^^')

### Expected behaviour

only the `bar`'s scope should rename, i.e. resulting in an invalid program or (more complicated, inserting `{foo = bar, ..}` into the record wild card.

### Debug information

I haven't tried on 2.14.0.0.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the supplied Haskell RecordWildCards example and compare renaming the local `foo` with renaming the record field. Trace Haskell Language Server’s rename handling for this case and check it against the stated expected scope; done means the local binding is not treated as the record field.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.