Skip to content

HLint reports incorrect redundant irrefutable pattern #2280

Closed
@noughtmare

Description

@noughtmare

Your environment

Output of haskell-language-server --probe-tools or haskell-language-server-wrapper --probe-tools:

haskell-language-server version: 1.4.0.0 (GHC: 8.10.7) (PATH: /nix/store/mxpy0nnbirprj791gsbncmkrvi67g8x8-haskell-language-server-1.4.0.0/bin/haskell-language-server)
Tool versions found on the $PATH
cabal:		3.4.0.0
stack:		Not found
ghc:		8.10.4

Which OS do you use: NixOS 21.05

Which lsp-client do you use: Coc on Neovim (same issue in VS Codium)

Describe your project (alternative: link to the project):

{-# LANGUAGE Strict #-}
f ~x = x

Steps to reproduce

Load the file.

Expected behaviour

No HLint warnings.

Actual behaviour

A HLint warning about a redundant irrefutable pattern:

[hlint refact:Redundant irrefutable pattern] [I] Redundant irrefutable pattern
Found:
  ~x
Why not:
  x

Other comment

Running hlint (version 3.3.4) manually does work correctly.

Include debug information

Execute in the root of your project the command haskell-language-server --debug . and paste the logs here:

Debug output:
No 'hie.yaml' found. Try to discover the project type!
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 1.4.0.0 x86_64 ghc-8.10.7
Current directory: /tmp
Operating system: linux
Arguments: ["--debug","B.hs"]
Cradle directory: /tmp
Cradle type: Default

Tool versions found on the $PATH
cabal:		3.4.0.0
stack:		Not found
ghc:		8.10.4


Consulting the cradle to get project GHC version...
Project GHC version: 8.10.4
haskell-language-server exe candidates: ["haskell-language-server-8.10.4","haskell-language-server"]
Launching haskell-language-server exe at:/run/current-system/sw/bin/haskell-language-server-8.10.4
haskell-language-server version: 1.1.0.0 (GHC: 8.10.4) (PATH: /nix/store/xx32gx7bl1w2wk588h1bm02r8xcvflyc-haskell-language-server-1.1.0.0/bin/haskell-language-server)
 ghcide setup tester in /tmp.
Report bugs at https://github.com/haskell/haskell-language-server/issues

Step 1/4: Finding files to test in /tmp
Found 1 files

Step 2/4: Looking for hie.yaml files that control setup
Found 1 cradle
  ()

Step 3/4: Initializing the IDE

Step 4/4: Type checking the files
2021-10-17 12:17:38.596480804 [ThreadId 4] DEBUG hls:	Set files of interest to: [(NormalizedFilePath "/tmp/B.hs",OnDisk)]
2021-10-17 12:17:38.597551851 [ThreadId 55] DEBUG hls:	hlint:getIdeas:file:NormalizedFilePath "/tmp/B.hs"
2021-10-17 12:17:38.597612089 [ThreadId 51] INFO hls:	Consulting the cradle for "B.hs"
2021-10-17 12:17:38.597769827 [ThreadId 51] WARNING hls:	No [cradle](https://github.com/mpickering/hie-bios#hie-bios) found for B.hs.
 Proceeding with [implicit cradle](https://hackage.haskell.org/package/implicit-hie).
You should ignore this message, unless you see a 'Multi Cradle: No prefixes matched' error.
Output from setting up the cradle Cradle {cradleRootDir = "/tmp", cradleOptsProg = CradleAction: Default}
2021-10-17 12:17:38.648808824 [ThreadId 51] DEBUG hls:	Session loading result: Right (ComponentOptions {componentOptions = [], componentRoot = "/tmp", componentDependencies = []},"/nix/store/218lyjhz8z28zs24a7pzvzlkd0ds1x6v-ghc-8.10.4/lib/ghc-8.10.4")
2021-10-17 12:17:38.866041644 [ThreadId 51] INFO hls:	Using interface files cache dir: /home/user/.cache/ghcide/main-da39a3ee5e6b4b0d3255bfef95601890afd80709
2021-10-17 12:17:38.866187848 [ThreadId 51] INFO hls:	Making new HscEnv[main]
2021-10-17 12:17:38.94827923 [ThreadId 51] DEBUG hls:	New Component Cache HscEnvEq: (([],Just HscEnvEq 5),fromList [])
2021-10-17 12:17:38.948421578 [ThreadId 51] DEBUG hls:	Known files updated: fromList [(TargetFile NormalizedFilePath "/tmp/B.hs",fromList ["/tmp/B.hs"])]
2021-10-17 12:17:38.948852036 [ThreadId 51] DEBUG hls:	Restarting build session (aborting the previous one took 0.00s)
2021-10-17 12:17:38.948985389 [ThreadId 18] DEBUG hls:	Finishing build session(exception: AsyncCancelled)
2021-10-17 12:17:38.949852794 [ThreadId 98] DEBUG hls:	hlint:getIdeas:file:NormalizedFilePath "/tmp/B.hs"
2021-10-17 12:17:38.971232375 [ThreadId 129] INFO hls:	File:     /tmp/B.hs
Hidden:   no
Range:    3:3-3:5
Source:   hlint
Severity: DsInfo
Message:  Redundant irrefutable patternFound:~xWhy not:x
2021-10-17 12:17:38.973153623 [ThreadId 148] INFO hls:	finish: User TypeCheck (took 0.02s)
2021-10-17 12:17:38.974465996 [ThreadId 157] INFO hls:	finish: GetHie (took 0.00s)

Completed (1 file worked, 0 files failed)
2021-10-17 12:17:38.974682775 [ThreadId 158] INFO hls:	finish: GenerateCore (took 0.00s)

Paste the logs from the lsp-client, e.g. for VS Code

LSP logs:
## Log of coc.nvim

2021-10-17T12:18:40.910 INFO (pid:5586) [services] - registered service "languageserver.haskell"
2021-10-17T12:18:40.916 INFO (pid:5586) [services] - haskell state change: stopped => starting
2021-10-17T12:18:40.919 INFO (pid:5586) [plugin] - coc.nvim 0.0.80-03c9add7cd initialized with node: v14.17.6 after 69ms
2021-10-17T12:18:40.924 INFO (pid:5586) [language-client-index] - Language server "languageserver.haskell" started with 5597
2021-10-17T12:18:41.094 INFO (pid:5586) [services] - haskell state change: starting => running
2021-10-17T12:18:41.100 INFO (pid:5586) [services] - service languageserver.haskell started
2021-10-17T12:18:45.295 INFO (pid:5586) [attach] - receive notification: runCommand [ 'workspace.showOutput' ]
2021-10-17T12:18:53.831 INFO (pid:5586) [attach] - receive notification: showInfo []

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: hls-hlint-plugintype: 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