Rearrange error msgs and add section markers (Trac #11014).
authorEvan Laforge <qdunkan@gmail.com>
Tue, 24 Nov 2015 11:43:18 +0000 (12:43 +0100)
committerBen Gamari <ben@smart-cactus.org>
Tue, 24 Nov 2015 13:02:58 +0000 (14:02 +0100)
commitc05fdddec71f9dc8ebe62d751ccf03367128072a
tree4afadb128af4af0f99dfb92fdbb9607bbeb64f04
parentf09f2470a76bb08b7f51d2f5663daa672b86f618
Rearrange error msgs and add section markers (Trac #11014).

This puts the "Relevant bindings" section at the end.

It uses a TcErrors.Report Monoid to divide messages by importance and
then mappends them together.  This is not the most efficient way since
there are various intermediate Reports and list appends, but it probably
doesn't matter since error messages shouldn't get that large, and are
usually prepended.  In practice, everything is `important` except
`relevantBindings`, which is `supplementary`.

ErrMsg's errMsgShortDoc and errMsgExtraInfo were extracted into ErrDoc,
which has important, context, and suppelementary fields.  Each of those
three sections is marked with a bullet character, '•' on unicode
terminals and '*' on ascii terminals.  Since this breaks tons of tests,
I also modified testlib.normalise_errmsg to strip out '•'s.

--- Additional notes:

To avoid prepending * to an empty doc, I needed to filter empty docs.
This seemed less error-prone than trying to modify everyone who produces
SDoc to instead produce Maybe SDoc.  So I added `Outputable.isEmpty`.
Unfortunately it needs a DynFlags, which is kind of bogus, but otherwise
I think I'd need another Empty case for SDoc, and then it couldn't be a
newtype any more.

ErrMsg's errMsgShortString is only used by the Show instance, which is
in turn only used by Show HscTypes.SourceError, which is in turn only
needed for the Exception instance.  So it's probably possible to get rid
of errMsgShortString, but that would a be an unrelated cleanup.

Fixes #11014.

Test Plan: see above

Reviewers: austin, simonpj, thomie, bgamari

Reviewed By: thomie, bgamari

Subscribers: simonpj, nomeata, thomie

Differential Revision: https://phabricator.haskell.org/D1427

GHC Trac Issues: #11014
148 files changed:
compiler/cmm/CmmLayoutStack.hs
compiler/main/ErrUtils.hs
compiler/typecheck/TcErrors.hs
compiler/typecheck/TcRnMonad.hs
compiler/utils/Outputable.hs
testsuite/driver/testlib.py
testsuite/tests/arrows/should_fail/T5380.stderr
testsuite/tests/driver/T2507.stderr
testsuite/tests/driver/T6037.stderr
testsuite/tests/driver/T8959a.stderr
testsuite/tests/gadt/T3169.stderr
testsuite/tests/gadt/T7558.stderr
testsuite/tests/gadt/gadt-escape1.stderr
testsuite/tests/gadt/gadt13.stderr
testsuite/tests/gadt/gadt7.stderr
testsuite/tests/gadt/rw.stderr
testsuite/tests/ghci/scripts/Defer02.stderr
testsuite/tests/ghci/scripts/ghci050.stderr
testsuite/tests/indexed-types/should_compile/PushedInAsGivens.stderr
testsuite/tests/indexed-types/should_compile/T3208b.stderr
testsuite/tests/indexed-types/should_fail/ExtraTcsUntch.stderr
testsuite/tests/indexed-types/should_fail/GADTwrong1.stderr
testsuite/tests/indexed-types/should_fail/Overlap10.stderr
testsuite/tests/indexed-types/should_fail/Overlap11.stderr
testsuite/tests/indexed-types/should_fail/Overlap15.stderr
testsuite/tests/indexed-types/should_fail/Overlap6.stderr
testsuite/tests/indexed-types/should_fail/Overlap9.stderr
testsuite/tests/indexed-types/should_fail/SimpleFail16.stderr
testsuite/tests/indexed-types/should_fail/SimpleFail5a.stderr
testsuite/tests/indexed-types/should_fail/T2544.stderr
testsuite/tests/indexed-types/should_fail/T2664.stderr
testsuite/tests/indexed-types/should_fail/T2693.stderr
testsuite/tests/indexed-types/should_fail/T3330a.stderr
testsuite/tests/indexed-types/should_fail/T3330c.stderr
testsuite/tests/indexed-types/should_fail/T3440.stderr
testsuite/tests/indexed-types/should_fail/T4093a.stderr
testsuite/tests/indexed-types/should_fail/T4093b.stderr
testsuite/tests/indexed-types/should_fail/T4099.stderr
testsuite/tests/indexed-types/should_fail/T4174.stderr
testsuite/tests/indexed-types/should_fail/T4179.stderr
testsuite/tests/indexed-types/should_fail/T4272.stderr
testsuite/tests/indexed-types/should_fail/T5439.stderr
testsuite/tests/indexed-types/should_fail/T6123.stderr
testsuite/tests/indexed-types/should_fail/T7194.stderr
testsuite/tests/indexed-types/should_fail/T7354.stderr
testsuite/tests/indexed-types/should_fail/T7354a.stderr
testsuite/tests/indexed-types/should_fail/T7729.stderr
testsuite/tests/indexed-types/should_fail/T7729a.stderr
testsuite/tests/indexed-types/should_fail/T7786.stderr
testsuite/tests/indexed-types/should_fail/T8129.stdout
testsuite/tests/indexed-types/should_fail/T8227.stderr
testsuite/tests/indexed-types/should_fail/T8518.stderr
testsuite/tests/indexed-types/should_fail/T9662.stderr
testsuite/tests/module/mod71.stderr
testsuite/tests/parser/should_fail/T7848.stderr
testsuite/tests/parser/should_fail/readFail003.stderr
testsuite/tests/partial-sigs/should_compile/SplicesUsed.stderr
testsuite/tests/partial-sigs/should_compile/T10438.stderr
testsuite/tests/partial-sigs/should_compile/T10463.stderr
testsuite/tests/partial-sigs/should_compile/TypedSplice.stderr
testsuite/tests/partial-sigs/should_fail/NamedWildcardsNotEnabled.stderr
testsuite/tests/partial-sigs/should_fail/T10045.stderr
testsuite/tests/partial-sigs/should_fail/T10615.stderr
testsuite/tests/partial-sigs/should_fail/Trac10045.stderr
testsuite/tests/partial-sigs/should_fail/WildcardsInPatternAndExprSig.stderr
testsuite/tests/polykinds/T7230.stderr
testsuite/tests/polykinds/T7438.stderr
testsuite/tests/polykinds/T7594.stderr
testsuite/tests/simplCore/should_compile/simpl017.stderr
testsuite/tests/th/T10267.stderr
testsuite/tests/th/T7276a.stdout
testsuite/tests/typecheck/should_compile/FD1.stderr
testsuite/tests/typecheck/should_compile/FD2.stderr
testsuite/tests/typecheck/should_compile/FD3.stderr
testsuite/tests/typecheck/should_compile/T2494.stderr
testsuite/tests/typecheck/should_compile/T9497a.stderr
testsuite/tests/typecheck/should_compile/T9834.stderr
testsuite/tests/typecheck/should_compile/holes.stderr
testsuite/tests/typecheck/should_compile/holes2.stderr
testsuite/tests/typecheck/should_compile/holes3.stderr
testsuite/tests/typecheck/should_compile/tc141.stderr
testsuite/tests/typecheck/should_fail/FDsFromGivens2.stderr
testsuite/tests/typecheck/should_fail/FrozenErrorTests.stderr
testsuite/tests/typecheck/should_fail/T10285.stderr
testsuite/tests/typecheck/should_fail/T10495.stderr
testsuite/tests/typecheck/should_fail/T10534.stderr
testsuite/tests/typecheck/should_fail/T10715b.stderr
testsuite/tests/typecheck/should_fail/T1899.stderr
testsuite/tests/typecheck/should_fail/T2534.stderr
testsuite/tests/typecheck/should_fail/T2688.stderr
testsuite/tests/typecheck/should_fail/T2714.stderr
testsuite/tests/typecheck/should_fail/T3950.stderr
testsuite/tests/typecheck/should_fail/T5689.stderr
testsuite/tests/typecheck/should_fail/T5853.stderr
testsuite/tests/typecheck/should_fail/T7264.stderr
testsuite/tests/typecheck/should_fail/T7368a.stderr
testsuite/tests/typecheck/should_fail/T7453.stderr
testsuite/tests/typecheck/should_fail/T7696.stderr
testsuite/tests/typecheck/should_fail/T7734.stderr
testsuite/tests/typecheck/should_fail/T7748a.stderr
testsuite/tests/typecheck/should_fail/T7869.stderr
testsuite/tests/typecheck/should_fail/T8044.stderr
testsuite/tests/typecheck/should_fail/T8142.stderr
testsuite/tests/typecheck/should_fail/T8262.stderr
testsuite/tests/typecheck/should_fail/T8428.stderr
testsuite/tests/typecheck/should_fail/T8450.stderr
testsuite/tests/typecheck/should_fail/T9109.stderr
testsuite/tests/typecheck/should_fail/T9497d.stderr
testsuite/tests/typecheck/should_fail/T9605.stderr
testsuite/tests/typecheck/should_fail/T9612.stderr
testsuite/tests/typecheck/should_fail/TcCoercibleFail.stderr
testsuite/tests/typecheck/should_fail/mc22.stderr
testsuite/tests/typecheck/should_fail/mc23.stderr
testsuite/tests/typecheck/should_fail/mc24.stderr
testsuite/tests/typecheck/should_fail/mc25.stderr
testsuite/tests/typecheck/should_fail/tcfail001.stderr
testsuite/tests/typecheck/should_fail/tcfail002.stderr
testsuite/tests/typecheck/should_fail/tcfail004.stderr
testsuite/tests/typecheck/should_fail/tcfail005.stderr
testsuite/tests/typecheck/should_fail/tcfail013.stderr
testsuite/tests/typecheck/should_fail/tcfail014.stderr
testsuite/tests/typecheck/should_fail/tcfail016.stderr
testsuite/tests/typecheck/should_fail/tcfail032.stderr
testsuite/tests/typecheck/should_fail/tcfail033.stderr
testsuite/tests/typecheck/should_fail/tcfail065.stderr
testsuite/tests/typecheck/should_fail/tcfail068.stderr
testsuite/tests/typecheck/should_fail/tcfail076.stderr
testsuite/tests/typecheck/should_fail/tcfail099.stderr
testsuite/tests/typecheck/should_fail/tcfail103.stderr
testsuite/tests/typecheck/should_fail/tcfail122.stderr
testsuite/tests/typecheck/should_fail/tcfail131.stderr
testsuite/tests/typecheck/should_fail/tcfail140.stderr
testsuite/tests/typecheck/should_fail/tcfail153.stderr
testsuite/tests/typecheck/should_fail/tcfail174.stderr
testsuite/tests/typecheck/should_fail/tcfail175.stderr
testsuite/tests/typecheck/should_fail/tcfail178.stderr
testsuite/tests/typecheck/should_fail/tcfail179.stderr
testsuite/tests/typecheck/should_fail/tcfail182.stderr
testsuite/tests/typecheck/should_fail/tcfail198.stderr
testsuite/tests/typecheck/should_fail/tcfail200.stderr
testsuite/tests/typecheck/should_fail/tcfail201.stderr
testsuite/tests/typecheck/should_fail/tcfail206.stderr
testsuite/tests/typecheck/should_run/T10284.stdout
testsuite/tests/typecheck/should_run/T7861.stderr
testsuite/tests/typecheck/should_run/T9497a-run.stderr
testsuite/tests/typecheck/should_run/T9497b-run.stderr
testsuite/tests/typecheck/should_run/T9497c-run.stderr
testsuite/tests/typecheck/should_run/tcrun035.stderr