haskell / haskell/haskell-language-server

Case split refers to out of scope patterns without adding imports or qualifying

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

Description

This isn't really an issue for me currently (hence the contrived hide prelude example) but thought it was worth raising regardless. I think not using a qualified name if available is probably a bigger problem than not auto importing because you might be matching something with many patterns you don't want to bring into the normal scope. (Also beware of qualified operators.)

### Your environment

Windows
GHC 9.14.1 (from HLS)
Project build by cabal (but probably possible in a single file)
VSCode + vscode-haskell
HLS 2.15.0.0 via ghcup compile
Config - HLS managed by PATH, semantic tokens on

### Steps to reproduce

Complete the `\case`

```Haskell
module MyLib where
import Prelude (Maybe)
-- import qualified Data.Maybe -- doesn't fix the issue

test :: Maybe a -> ()
test = \case
```

### Expected behaviour

It will auto-import (somehow) similar to auto-completion, or use a qualified name if available (e.g. the various correction suggestions HLS will give after the change).

### Actual behaviour

It will refer to (out of scope) `Just` and `Nothing`

### Debug information

None

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the issue in HLS using the provided MyLib module and complete the \case expression. Start by locating the case-split completion or code-action entry point and its existing tests; no specific files or tests are named in the report. Done means the suggestions import or qualify Just and Nothing instead of producing out-of-scope names.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell, vscode
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.