haskell / haskell/haskell-language-server

Inline function with guard only pick first guard case

Open
#4,374 7 comments 0 reactions 0 assignees View on GitHub
component: hls-refactor-plugin component: hls-retrie-plugin status: blocked type: bug
Dominant language
Haskell
Stars
3k
Forks
455
Avg merge
2d 19h
Merged PRs (30d)
11

Description

### Your environment

Which OS do you use? Linux
Which version of GHC do you use and how did you install it?

Tested with ghc 9.6.5 and 9.8.2 installed with nix.

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

Single file

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

neovim + neovim-lsp

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

2.9.0.0 installed from nixpkgs.

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

No hie file, single file support

### Steps to reproduce

The following file:

```haskell
foo x y
| x == 0 = y
| otherwise = x + y

bar = foo 1 2
```

The code action on the `foo` call, called `inline foo`

### Expected behaviour

`foo` (in `bar`)should be replaced by equivalent piece of code, so I assume something like:

```haskell
bar = if 1 == 0 then 2 else 1 + 2
```

(or something equivalent).

### Actual behaviour

Looks like only the first case of `foo` implementation is taken into account, and hence, I get:

```
bar = 2
```

See for yourself:

https://github.com/user-attachments/assets/a0ad59d3-4c41-41e0-b71b-9f606181efa7

### Debug information

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.