haskell / haskell/haskell-language-server

Ormolu/Fourmolu incorrectly infers `GHC2021` in Stack projects

Open
#3,439 9 comments 7 reactions 0 assignees View on GitHub
build tool: stack component: formatters type: bug
Dominant language
Haskell
Stars
3k
Forks
455
Avg merge
4d 3h
Merged PRs (30d)
12

Description

**Summary:** Formatting via HLS moves my `qualified` keywords as if I had the `ImportQualifiedPost` plugin enabled, which I do not. Interestingly, this bug only seems to occur in projects using GHC 9.2.5?

Note that I've tried the standalone ormolu (`0.5.1`) and this problem does *not* occur. I can't figure out how to check which version of ormolu my HLS is using, however...

### Your environment

Which OS do you use?

Ubuntu 20.04

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

9.2.5, installed via stack.

**NOTE:** I tried this in an older project, using GHC 9.0.2 (also via stack), and the bug did NOT occur.

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

stack

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

Tried in neovim 0.8.2 and vs code 1.74.2 with same result.

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

HLS 1.9.0, via ghcup.

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

No extra configs

### Steps to reproduce

0. Verify that `ImportQualifiedPost` is not enabled anywhere in the project
1. Add a qualified import
2. Use HLS to format the file

### Expected behaviour

The following import should remain as-is:
```
import qualified Data.Text as T
```

### Actual behaviour

The import is altered, `qualified` is moved:
```
import Data.Text qualified as T
```

### Debug information

N/A

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.