Major patch to add -fwarn-redundant-constraints
authorSimon Peyton Jones <simonpj@microsoft.com>
Mon, 5 Jan 2015 13:20:48 +0000 (13:20 +0000)
committerSimon Peyton Jones <simonpj@microsoft.com>
Tue, 6 Jan 2015 14:21:13 +0000 (14:21 +0000)
commit32973bf3c2f6fe00e01b44a63ac1904080466938
treedcefa6b0b92f2cefda9c0ce8944169da0036d598
parentda9b2ec3e19edb1de0e73e8f32aa0443743f072c
Major patch to add -fwarn-redundant-constraints

The idea was promted by Trac #9939, but it was Christmas, so I did
some recreational programming that went much further.

The idea is to warn when a constraint in a user-supplied context is
redundant.  Everything is described in detail in
  Note [Tracking redundant constraints]
in TcSimplify.

Main changes:

 * The new ic_status field in an implication, of type ImplicStatus.
   It replaces ic_insol, and includes information about redundant
   constraints.

 * New function TcSimplify.setImplicationStatus sets the ic_status.

 * TcSigInfo has sig_report_redundant field to say whenther a
   redundant constraint should be reported; and similarly
   the FunSigCtxt constructor of UserTypeCtxt

 * EvBinds has a field eb_is_given, to record whether it is a given
   or wanted binding. Some consequential chagnes to creating an evidence
   binding (so that we record whether it is given or wanted).

 * AbsBinds field abs_ev_binds is now a *list* of TcEvBiinds;
   see Note [Typechecking plan for instance declarations] in
   TcInstDcls

 * Some significant changes to the type checking of instance
   declarations; Note [Typechecking plan for instance declarations]
   in TcInstDcls.

 * I found that TcErrors.relevantBindings was failing to zonk the
   origin of the constraint it was looking at, and hence failing to
   find some relevant bindings.  Easy to fix, and orthogonal to
   everything else, but hard to disentangle.

Some minor refactorig:

 * TcMType.newSimpleWanteds moves to Inst, renamed as newWanteds

 * TcClassDcl and TcInstDcls now have their own code for typechecking
   a method body, rather than sharing a single function. The shared
   function (ws TcClassDcl.tcInstanceMethodBody) didn't have much code
   and the differences were growing confusing.

 * Add new function TcRnMonad.pushLevelAndCaptureConstraints, and
   use it

 * Add new function Bag.catBagMaybes, and use it in TcSimplify
207 files changed:
compiler/basicTypes/BasicTypes.hs
compiler/deSugar/DsArrows.hs
compiler/deSugar/DsBinds.hs
compiler/deSugar/DsExpr.hs
compiler/hsSyn/HsBinds.hs
compiler/iface/BuildTyCl.hs
compiler/iface/IfaceSyn.hs
compiler/main/DynFlags.hs
compiler/typecheck/Inst.hs
compiler/typecheck/TcBinds.hs
compiler/typecheck/TcCanonical.hs
compiler/typecheck/TcClassDcl.hs
compiler/typecheck/TcDeriv.hs
compiler/typecheck/TcErrors.hs
compiler/typecheck/TcEvidence.hs
compiler/typecheck/TcFlatten.hs
compiler/typecheck/TcHsSyn.hs
compiler/typecheck/TcInstDcls.hs
compiler/typecheck/TcInteract.hs
compiler/typecheck/TcMType.hs
compiler/typecheck/TcMatches.hs
compiler/typecheck/TcPat.hs
compiler/typecheck/TcPatSyn.hs
compiler/typecheck/TcRnDriver.hs
compiler/typecheck/TcRnMonad.hs
compiler/typecheck/TcRnTypes.hs
compiler/typecheck/TcRules.hs
compiler/typecheck/TcSMonad.hs
compiler/typecheck/TcSimplify.hs
compiler/typecheck/TcTyClsDecls.hs
compiler/typecheck/TcType.hs
compiler/typecheck/TcUnify.hs
compiler/typecheck/TcValidity.hs
compiler/utils/Bag.hs
compiler/utils/Util.hs
docs/users_guide/using.xml
testsuite/tests/arrows/should_compile/arrowpat.hs
testsuite/tests/codeGen/should_compile/T3286.hs
testsuite/tests/deriving/should_compile/T2856.hs
testsuite/tests/deriving/should_compile/T4966.hs
testsuite/tests/deriving/should_compile/T4966.stderr
testsuite/tests/deriving/should_compile/deriving-1935.hs
testsuite/tests/deriving/should_compile/deriving-1935.stderr
testsuite/tests/deriving/should_compile/drv001.hs
testsuite/tests/deriving/should_compile/drv002.hs
testsuite/tests/deriving/should_compile/drv003.hs
testsuite/tests/deriving/should_compile/drv003.stderr
testsuite/tests/deriving/should_run/T9576.stderr
testsuite/tests/gadt/Gadt17_help.hs
testsuite/tests/ghci/scripts/T5045.hs
testsuite/tests/ghci/scripts/T8357.hs
testsuite/tests/ghci/scripts/T8931.script
testsuite/tests/ghci/scripts/ghci044.script
testsuite/tests/ghci/scripts/ghci044.stderr
testsuite/tests/ghci/scripts/ghci047.script
testsuite/tests/ghci/scripts/ghci047.stderr
testsuite/tests/haddock/haddock_examples/Test.hs
testsuite/tests/haddock/haddock_examples/haddock.Test.stderr
testsuite/tests/haddock/should_compile_flag_haddock/haddockA023.hs
testsuite/tests/haddock/should_compile_flag_haddock/haddockA026.hs
testsuite/tests/haddock/should_compile_flag_haddock/haddockA027.hs
testsuite/tests/haddock/should_compile_noflag_haddock/haddockC026.hs
testsuite/tests/haddock/should_compile_noflag_haddock/haddockC027.hs
testsuite/tests/indexed-types/should_compile/Class2.hs
testsuite/tests/indexed-types/should_compile/Gentle.hs
testsuite/tests/indexed-types/should_compile/InstContextNorm.hs
testsuite/tests/indexed-types/should_compile/InstEqContext.hs
testsuite/tests/indexed-types/should_compile/InstEqContext2.hs
testsuite/tests/indexed-types/should_compile/InstEqContext3.hs
testsuite/tests/indexed-types/should_compile/NonLinearLHS.hs
testsuite/tests/indexed-types/should_compile/Rules1.hs
testsuite/tests/indexed-types/should_compile/Simple24.hs
testsuite/tests/indexed-types/should_compile/T2448.hs
testsuite/tests/indexed-types/should_compile/T3023.hs
testsuite/tests/indexed-types/should_compile/T3023.stderr
testsuite/tests/indexed-types/should_compile/T3484.hs
testsuite/tests/indexed-types/should_compile/T4200.hs
testsuite/tests/indexed-types/should_compile/T4497.hs
testsuite/tests/indexed-types/should_compile/T4981-V1.hs
testsuite/tests/indexed-types/should_compile/T4981-V2.hs
testsuite/tests/indexed-types/should_compile/T4981-V3.hs
testsuite/tests/indexed-types/should_compile/T5002.hs
testsuite/tests/indexed-types/should_compile/T9090.hs
testsuite/tests/indexed-types/should_compile/T9316.hs
testsuite/tests/indexed-types/should_compile/T9747.hs
testsuite/tests/indexed-types/should_fail/T2239.hs
testsuite/tests/indexed-types/should_fail/T3330c.stderr
testsuite/tests/indexed-types/should_fail/T7862.hs
testsuite/tests/indexed-types/should_fail/T7862.stderr
testsuite/tests/module/mod129.hs
testsuite/tests/module/mod71.stderr
testsuite/tests/parser/should_compile/mc15.hs
testsuite/tests/parser/should_compile/read002.hs
testsuite/tests/partial-sigs/should_compile/all.T
testsuite/tests/patsyn/should_compile/T8584-2.hs
testsuite/tests/patsyn/should_compile/T8968-1.hs
testsuite/tests/patsyn/should_compile/all.T
testsuite/tests/patsyn/should_compile/ex-view.hs
testsuite/tests/perf/compiler/T3064.hs
testsuite/tests/perf/compiler/T5030.hs
testsuite/tests/polykinds/PolyKinds08.hs
testsuite/tests/polykinds/T6015a.hs
testsuite/tests/polykinds/T6020a.hs
testsuite/tests/polykinds/T6068.hs
testsuite/tests/polykinds/T7090.hs
testsuite/tests/polykinds/T7332.hs
testsuite/tests/polykinds/T8359.hs
testsuite/tests/polykinds/T9569.hs
testsuite/tests/polykinds/T9750.hs
testsuite/tests/rebindable/T5821.hs
testsuite/tests/rebindable/rebindable9.hs
testsuite/tests/rename/should_fail/rnfail020.hs
testsuite/tests/simplCore/should_compile/T3831.hs
testsuite/tests/simplCore/should_compile/T4398.hs
testsuite/tests/simplCore/should_compile/T4398.stderr
testsuite/tests/simplCore/should_compile/T5329.hs
testsuite/tests/simplCore/should_compile/T5342.hs
testsuite/tests/simplCore/should_compile/T5359b.hs
testsuite/tests/simplCore/should_compile/T5359b.stderr
testsuite/tests/simplCore/should_compile/T8848.hs
testsuite/tests/simplCore/should_compile/T8848.stderr
testsuite/tests/simplCore/should_compile/T8848a.hs
testsuite/tests/simplCore/should_compile/simpl002.hs
testsuite/tests/simplCore/should_compile/simpl007.hs
testsuite/tests/simplCore/should_compile/simpl014.hs
testsuite/tests/simplCore/should_compile/simpl016.hs
testsuite/tests/simplCore/should_compile/simpl016.stderr
testsuite/tests/simplCore/should_compile/spec003.hs
testsuite/tests/th/T3100.hs
testsuite/tests/th/T7021a.hs
testsuite/tests/th/T8807.hs
testsuite/tests/th/TH_tf3.hs
testsuite/tests/typecheck/should_compile/GivenOverlapping.hs
testsuite/tests/typecheck/should_compile/LoopOfTheDay1.hs
testsuite/tests/typecheck/should_compile/LoopOfTheDay2.hs
testsuite/tests/typecheck/should_compile/LoopOfTheDay3.hs
testsuite/tests/typecheck/should_compile/T1470.hs
testsuite/tests/typecheck/should_compile/T2683.hs
testsuite/tests/typecheck/should_compile/T3018.hs
testsuite/tests/typecheck/should_compile/T3108.hs
testsuite/tests/typecheck/should_compile/T3692.hs
testsuite/tests/typecheck/should_compile/T3743.hs
testsuite/tests/typecheck/should_compile/T4361.hs
testsuite/tests/typecheck/should_compile/T4401.hs
testsuite/tests/typecheck/should_compile/T4524.hs
testsuite/tests/typecheck/should_compile/T4952.hs
testsuite/tests/typecheck/should_compile/T4969.hs
testsuite/tests/typecheck/should_compile/T5514.hs
testsuite/tests/typecheck/should_compile/T5581.hs
testsuite/tests/typecheck/should_compile/T5676.hs
testsuite/tests/typecheck/should_compile/T6055.hs
testsuite/tests/typecheck/should_compile/T6134.hs
testsuite/tests/typecheck/should_compile/T7171a.hs
testsuite/tests/typecheck/should_compile/T7196.hs
testsuite/tests/typecheck/should_compile/T7220.hs
testsuite/tests/typecheck/should_compile/T7541.hs
testsuite/tests/typecheck/should_compile/T7875.hs
testsuite/tests/typecheck/should_compile/T7903.hs
testsuite/tests/typecheck/should_compile/T7903.stderr-ghc
testsuite/tests/typecheck/should_compile/Tc170_Aux.hs
testsuite/tests/typecheck/should_compile/Tc173a.hs
testsuite/tests/typecheck/should_compile/tc045.hs
testsuite/tests/typecheck/should_compile/tc051.hs
testsuite/tests/typecheck/should_compile/tc056.stderr
testsuite/tests/typecheck/should_compile/tc058.hs
testsuite/tests/typecheck/should_compile/tc065.hs
testsuite/tests/typecheck/should_compile/tc078.hs
testsuite/tests/typecheck/should_compile/tc078.stderr-ghc
testsuite/tests/typecheck/should_compile/tc079.hs
testsuite/tests/typecheck/should_compile/tc088.hs
testsuite/tests/typecheck/should_compile/tc091.hs
testsuite/tests/typecheck/should_compile/tc092.hs
testsuite/tests/typecheck/should_compile/tc109.hs
testsuite/tests/typecheck/should_compile/tc113.hs
testsuite/tests/typecheck/should_compile/tc115.hs
testsuite/tests/typecheck/should_compile/tc115.stderr-ghc
testsuite/tests/typecheck/should_compile/tc116.hs
testsuite/tests/typecheck/should_compile/tc116.stderr-ghc
testsuite/tests/typecheck/should_compile/tc125.hs
testsuite/tests/typecheck/should_compile/tc125.stderr-ghc
testsuite/tests/typecheck/should_compile/tc126.hs
testsuite/tests/typecheck/should_compile/tc126.stderr-ghc
testsuite/tests/typecheck/should_compile/tc145.hs
testsuite/tests/typecheck/should_compile/tc152.hs
testsuite/tests/typecheck/should_compile/tc176.hs
testsuite/tests/typecheck/should_compile/tc178.hs
testsuite/tests/typecheck/should_compile/tc180.hs
testsuite/tests/typecheck/should_compile/tc181.hs
testsuite/tests/typecheck/should_compile/tc183.hs
testsuite/tests/typecheck/should_compile/tc187.hs
testsuite/tests/typecheck/should_compile/tc192.hs
testsuite/tests/typecheck/should_compile/tc203.hs
testsuite/tests/typecheck/should_compile/tc204.hs
testsuite/tests/typecheck/should_compile/tc206.hs
testsuite/tests/typecheck/should_compile/tc208.hs
testsuite/tests/typecheck/should_compile/tc229.hs
testsuite/tests/typecheck/should_compile/tc230.hs
testsuite/tests/typecheck/should_compile/tc235.hs
testsuite/tests/typecheck/should_compile/tc237.hs
testsuite/tests/typecheck/should_compile/tc239.hs
testsuite/tests/typecheck/should_compile/twins.hs
testsuite/tests/typecheck/should_fail/T6161.stderr
testsuite/tests/typecheck/should_fail/tcfail017.stderr
testsuite/tests/typecheck/should_fail/tcfail020.stderr
testsuite/tests/typecheck/should_fail/tcfail071.hs
testsuite/tests/typecheck/should_fail/tcfail138.hs
testsuite/tests/typecheck/should_fail/tcfail143.stderr