haskell / haskell-language-server

Official haskell ide support via language server (LSP). Successor of ghcide & haskell-ide-engine.
Apache License 2.0
2.71k stars 368 forks source link

Use `-fno-show-error-context` #4281

Open michaelpj opened 5 months ago

michaelpj commented 5 months ago

Since 9.8 (https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8563) GHC has had the -fno-show-error-context flag, which makes GHC omit a bunch of contextual information that isn't really useful if you are directly showing the user the location of the error. That's exactly the situation we are in, we should use it!

michaelpj commented 5 months ago

I guess once we move to the full structured diagnostic infrastructure we'll be able to use the more sophisticated printing options, but for now just using the user-facing flag will help.

dsaenztagarro commented 5 months ago

@michaelpj I finally created a PR that uses correctly -fno-show-error-context, as per screenshots in the PR description.

That said, after introducing the change, I realised that some specs are broken, and I have verified in Visual Studio Code that the Code Action replace _ with xxxx changes slightly the behaviour when using the new option.

See Code Actions popover in the example below Screenshot 2024-06-08 at 22 55 32

For comparison, before the change:

Screenshot 2024-06-08 at 22 55 19 Screenshot 2024-06-08 at 22 55 44

After the change:

Screenshot 2024-06-08 at 22 58 18

So in the particular example above, when selecting replace _ with const, after the change the `` wrapping the hole are lost.

Any advice?

michaelpj commented 5 months ago

That's extremely weird. I guess we need to look a the code that is coming up with that information and check what it is doing?