haskell / haskell-ide-engine

The engine for haskell ide-integration. Not an IDE
BSD 3-Clause "New" or "Revised" License
2.38k stars 211 forks source link

What changes to GHC error reporting are required #7

Open alanz opened 8 years ago

alanz commented 8 years ago

There are a number of trac tickets related to the way GHC reports errors, with a view to improving them.

https://ghc.haskell.org/trac/ghc/ticket/8809 https://ghc.haskell.org/trac/ghc/ticket/10073 https://ghc.haskell.org/trac/ghc/ticket/10179

For tooling support, there should be an option to return errors in some kind of typed structure that can be easily an unambiguously processed by the tool.

This is in general a hard task, with deep tentacles into GHC.

Is there any low hanging fruit we can harvest in time for GHC 8.1?

gracjan commented 8 years ago

Important part of error message is the cross referencing information point to related files and lines of code. gcc and clang always put file name and line number as first information in output line:

file.cpp:12: ambiguous symbol 'xxx'
file.h:12: from a file included here
header.h:444: from a file included here

Sadly GHC likes to put paths to source files inside sentences so we have to discover where is the cross referencing information.

mgsloan commented 8 years ago

It would be great to have -fdefer-type-errors prepend something to the warnings which are outputted for errors (maybe "Error: "). I'd like to have -fdefer-type-errors be a default, but still present the messages as if they were errors.

alanz commented 8 years ago

I think there has been a change to prepend "error", will be in 8.0.1, may be in 7.10.2 already

On Tue, Oct 27, 2015 at 12:41 AM, Michael Sloan notifications@github.com wrote:

It would be great to have -fdefer-type-errors prepend something to the warnings which are outputted for errors (maybe "Error: "). I'd like to have -fdefer-type-errors be a default, but still present the messages as if they were errors.

— Reply to this email directly or view it on GitHub https://github.com/haskell/haskell-ide/issues/7#issuecomment-151305411.

cocreature commented 8 years ago

One thing that I keep stumbling upon is the fact that suggestions to enable pragmas always have slightly different formats causing tools which try to parse them such as haskell-mode to not recognize them in a lot of cases.

nponeccop commented 6 years ago

What about .cabal errors? Now there are errors which are returned without any file position information, so we can't put them as diagnostics.

jneira commented 4 years ago

As pointed by @mpickering there are a ghc proposal to implement structured errors: https://github.com/bgamari/ghc-proposals/blob/rich-errors-proposal/proposals/0000-rich-errors-proposal.rst. It is pretty recent (3 months).

To fix some bugs for windows i had to add more cases in parsing human readable ghc errors:

https://github.com/haskell/haskell-ide-engine/blob/538508774ac867a8f4d7bb61e591383b171fe964/test/functional/FunctionalCodeActionsSpec.hs#L224-L228

or

https://github.com/haskell/haskell-ide-engine/blob/538508774ac867a8f4d7bb61e591383b171fe964/src/Haskell/Ide/Engine/Plugin/HsImport.hs#L489-L501