Description
The circumstances in which this is manifested seem strangely specific, I might have mistitled. Essentially, when you try to use a type constructor as a data constructor, to the right of an arrow which pattern matches on any constructor in curtain situations, and where a data constructor with the same name as the type constructor is within "adding an identifier to existing import" away from HLS, this error manifests. More details on rep.
Your environment
Which OS do you use?
Linux 6.7.0, NixOS, 24.05 (Uakari), 24.05.20240108.317484b
Which version of GHC do you use, and how did you install it?
Version 9.4.8, installed via nixpkgs
How is your project built (alternative: link to the project)?
N/A
Which LSP client (editor/plugin) do you use?
VS Codium+vscode-haskell
Which version of HLS do you use, and how did you install it?
haskell-language-server version: 2.4.0.0 (GHC: 9.4.8), nixpkgs
Have you configured HLS in any way (especially: a hie.yaml
file)?
No
Steps to reproduce
module Bug where
import Data.Monoid (Sum) -- Note only the type constructor is imported, the correct import would be (Sum(Sum))
f (Just a) = Sum
As the cursor finishes writing Sum
(On VSCode
at least), internal error pop-ups will start to show up, hovering over it as well.
Scenarios I have tested
in all these cases, there are normal errors, ❌ (triggered) or ✅ (didn't trigger) only concerns if it triggered an internal error
f a = Sum -- ✅
f = Sum -- ✅
f = (\x -> Sum) -- ✅
f (Just a) = Sum -- ❌
f (a, b) = Sum -- ❌
f = (\(Just x) -> Sum) -- ❌
f = undefined . Sum -- ❌
f = Sum . undefined -- ❌
Explicit secondary module
Bug.hs
module Bug where
import BugBase (Foo)
f (Just a) = Foo
BugBase.hs
:
module BugBase where
data Foo = Foo
The above BugBase.hs
causes the internal error on Foo
at Bug.hs
, if BugBase.hs
had:
data Foo = MkFoo
No internal error is caused.
If we add a pattern synonym with the name Foo
, once again it errors on Bug.hs
:
{-# LANGUAGE PatternSynonyms #-}
module BugBase where
data Foo = MkFoo
pattern Foo = MkFoo
Debug information
The pop-up error (slightly formatted):
Error condition, please check your setup and/or the:
ghcide-code-actions-imports-exports:
Internal Error: Exception in plugin PluginId "ghcide-code-actions-imports-exports" while processing SMethod_TextDocumentCodeAction:
bug in srcspan parser CallStack (from HasCallStack):
error, called at src/Development/IDE/Plugin/CodeAction.hs:992:22 in hls-refactor-plugin-2.4.0.0-2s97y0YK1n42ouI0BG4EZp:Development.IDE.Plugin.CodeAction