Skip to content

WIP: Priorities for custom type errors

isovector requested to merge trac-isovector/ghc:better-type-errors into master

Custom type errors are often too loud; whenever they are emitted, they will suppress other error messages downstream from them. See #16906 (comment 212011) for an example of just how wrong this can go.

This MR introduces a new type family TypeErrorPriority parameterized by an ErrorPriority. These priorities correspond to report1 or report2 as generated by TcErrors.reportWanteds, and allow fine-grained reporting of error messages. For example, you can now report a custom error message that is only emitted if GHC doesn't want to emit any other error messages, such as insoluble equalities, or hole bindings.

It also introduces ShowTypePrec which is notably missing from the TypeError machinery, but I'm happy to move this (and some other constructors for ErrorMessage) into its own MR.

Merge request reports