Skip to content

WIP: compiler: introduce types for subsystem-specific errors

Alp Mestanogullari requested to merge alp/ghc:wip/alp/error-adt into master

Commit message:

This is the first step towards implementing ghc-proposals#306 (1). This patch introduces ParseError and TcRnError in the relevant subsystems as well as a toplevel GhcError sum type which can be constructed with a value of one of the two aforementioned types, or just a raw ErrMsg. GhcError however only exists at the driver-level and each subsystem gets to deal only with its corresponding error type.

At the moment, we use ParseError both when parsing Haskell source code as well as Cmm, and similarly the desugarer just reuses TcRnError as it shares a lot of infrastructure with the renamer+typechecker subsystem. This could be refined if deemed desirable.

This change alone is enough to compel us to make some error-related infrastructure a bit more generic, which this patch attempts to do. It does not yet delay the rendering of errors, as ParseError and TcRnError are mere wrappers for ErrMsg at this point. The addition of dedicated constructors for all the possible errors is delayed to a later patch, once the design for this one is consolidated (or changed a bit) and approved.

(1) https://github.com/ghc-proposals/ghc-proposals/pull/306

Note: this only tackles error messages and not warnings (yet?)

Edited by Alp Mestanogullari

Merge request reports