Skip to content

Simplify some error types.

In attempting to review !4728, I got sucked into a hole of refactoring. It started with being offended by warningsToMessages, which stores what should be warnings in something called ErrorMessages. (Yes, they're promoted warnings, but still.) Then, I got mad at the whole Severity/WarnReason mess, which needed tidying. It got a bit out of hand from there, but I'm quite pleased with the result.

Important point: I have not run this code -- building as I write.

I'm reminded of the time I visited my parents' house at a yearly gathering of larger family. Each sub-family had brought some food and added it to the fridge. It was a complete mess, and I spent a half hour taking everything out, coming up with organizing principles, and restocking, moving all duplicates to a second fridge downstairs. I'm not sure anyone really liked me just blasting ahead on this, but I'm convinced everyone enjoyed the week more for this work. And there are few things which make me feel more satisfied than arriving in a messy space and leaving a clean one.

Which is a roundabout way of saying: sorry if this steps on your toes. It does seem orthogonal to other changes. And I do think it's a nice improvement over the status quo. It really didn't start out being quite so big! :)

Curious for your thoughts, and it might be helpful for @simonpj to glance as well, especially at the changes in GHC.Tc.Errors.

Commit message follows:

Main changes:

  • Separate out MessageClass from Severity. The latter is used only to classify warnings vs errors, not other output.

  • Tuck WarnReason into SevWarning instead of having it as a separate field in ErrMsg.

  • Stop reclassifying warnings as errors with -Werror. Instead, just denote them as fatal warnings. This requires the propagation of DynFlags to more places, which is regrettable, but it cleans up the story around warnings vs errors quite nicely.

  • Warnings without a reason now say NoReason closer to where they are born.

  • Suppressed warnings (with -Wno-xyz) are now generated, but never printed. This is a simplification in the code in GHC.Tc.Errors, though there are more places to propagate this new design.

This patch is currently untested, but it compiles.

Merge request reports