Skip to content

HLint reports incorrect redundant irrefutable pattern #2280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
noughtmare opened this issue Oct 17, 2021 · 5 comments · Fixed by #2366
Closed

HLint reports incorrect redundant irrefutable pattern #2280

noughtmare opened this issue Oct 17, 2021 · 5 comments · Fixed by #2366
Labels
component: hls-hlint-plugin type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@noughtmare
Copy link
Contributor

noughtmare commented Oct 17, 2021

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 []
@jneira jneira added component: hls-hlint-plugin type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. labels Oct 17, 2021
@jneira
Copy link
Member

jneira commented Oct 18, 2021

@noughtmare hi, thanks for the bug report! i could be related with the fact we are using hlint-3.2.* for hls versions tied to ghc < 9.0.
Could you tried to reproduce using directly hlint-3.2 or try ghc-9.0 to check if that makes the warning go away? thanks!

@noughtmare
Copy link
Contributor Author

noughtmare commented Oct 18, 2021

I'm still getting "No hints" with HLint 3.2.

Edit: Using HLS with GHC 9.0.1 gives the same warnings.

@jneira
Copy link
Member

jneira commented Oct 18, 2021

many thanks for confirming it, then it could be related with the language extension, i guess the warning will appear if the language extension is not set in the file

@jneira
Copy link
Member

jneira commented Oct 19, 2021

hmm cant reproduce in vscode and hls 1.4.0 and ghc-8.6.5 (will try with 8.10.*)

imagen

imagen

Maybe you have a explicit NoStrict at another config scope and hlint does not honour the pragma? or you have an external hlint configuration with other extensions enabled?

@jneira
Copy link
Member

jneira commented Oct 19, 2021

hmm cant reproduce in vscode and hls 1.4.0 and ghc-8.6.5 (will try with 8.10.*)

Reproduced with 8.10.7 without a custom configuration for extensions, the cause is the way of setting extensions for hlint is different for 8.10 and the rest of ghc versions.

I think maybe the plugin is ignoring language pragmas in the module, so setting them in another scope (.cabal default-extensions, hlint external yaml config or using the haskell.plugin.hlint.config.flags option) could work

jneira added a commit to jneira/haskell-language-server that referenced this issue Nov 3, 2021
jneira added a commit to jneira/haskell-language-server that referenced this issue Nov 4, 2021
mergify bot pushed a commit that referenced this issue Nov 10, 2021
…#2321)

* Rename test data files

* Add regression tests

* Add regression test for #1279

* Use timeout

* Correct waitForProgressDone in ghcide

* Remove unnecessary waitForDiagnostics

* Mark test broken for hlint on ghclib

* Add test over unused extensions

* Add test for #2042

* Add data for #2280

* Use waitForAllProgressDone

* Add test for #2280

* correct module name

* Add reproduction for #2290

* Correct test case

* Comment about knownBrokenForHlint*

* Correction
jneira added a commit to jneira/haskell-language-server that referenced this issue Nov 18, 2021
jneira added a commit to jneira/haskell-language-server that referenced this issue Nov 18, 2021
@mergify mergify bot closed this as completed in #2366 Nov 19, 2021
mergify bot pushed a commit that referenced this issue Nov 19, 2021
…t comments (#2366)

* Replace * with -

* Use parsed module with comments

* Correct issue id

* Remove unknown broken for #638, #2042 and #2280
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: hls-hlint-plugin type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
2 participants