Improve typechecking of let-bindings
authorSimon Peyton Jones <simonpj@microsoft.com>
Sat, 11 Jun 2016 22:49:27 +0000 (23:49 +0100)
committerSimon Peyton Jones <simonpj@microsoft.com>
Mon, 13 Jun 2016 09:57:03 +0000 (10:57 +0100)
commit15b9bf4ba4ab47e6809bf2b3b36ec16e502aea72
treee2e7336c63e9b7130ba70f3551ff290d4a25184b
parentd25cb61a1c2a135a2564143a332f8b2962f134bc
Improve typechecking of let-bindings

This major commit was initially triggered by #11339, but it spiraled
into a major review of the way in which type signatures for bindings
are handled, especially partial type signatures.  On the way I fixed a
number of other bugs, namely
   #12069
   #12033
   #11700
   #11339
   #11670

The main change is that I completely reorganised the way in which type
signatures in bindings are handled. The new story is in TcSigs
Note [Overview of type signatures].  Some specific:

* Changes in the data types for signatures in TcRnTypes:
  TcIdSigInfo and new TcIdSigInst

* New module TcSigs deals with typechecking type signatures
  and pragmas. It contains code mostly moved from TcBinds,
  which is already too big

* HsTypes: I swapped the nesting of HsWildCardBndrs
  and HsImplicitBndsrs, so that the wildcards are on the
  oustide not the insidde in a LHsSigWcType.  This is just
  a matter of convenient, nothing deep.

There are a host of other changes as knock-on effects, and
it all took FAR longer than I anticipated :-).  But it is
a significant improvement, I think.

Lots of error messages changed slightly, some just variants but
some modest improvements.

New tests

* typecheck/should_compile
    * SigTyVars: a scoped-tyvar test
    * ExPat, ExPatFail: existential pattern bindings
    * T12069
    * T11700
    * T11339

* partial-sigs/should_compile
    * T12033
    * T11339a
    * T11670

One thing to check:

* Small change to output from ghc-api/landmines.
  Need to check with Alan Zimmerman
166 files changed:
compiler/deSugar/DsMeta.hs
compiler/deSugar/DsMonad.hs
compiler/ghc.cabal.in
compiler/hsSyn/HsTypes.hs
compiler/hsSyn/HsUtils.hs
compiler/rename/RnTypes.hs
compiler/typecheck/TcBinds.hs
compiler/typecheck/TcClassDcl.hs
compiler/typecheck/TcEnv.hs
compiler/typecheck/TcErrors.hs
compiler/typecheck/TcExpr.hs
compiler/typecheck/TcHsType.hs
compiler/typecheck/TcInstDcls.hs
compiler/typecheck/TcMType.hs
compiler/typecheck/TcPat.hs
compiler/typecheck/TcPatSyn.hs
compiler/typecheck/TcPatSyn.hs-boot
compiler/typecheck/TcRnDriver.hs
compiler/typecheck/TcRnMonad.hs
compiler/typecheck/TcRnTypes.hs
compiler/typecheck/TcRules.hs
compiler/typecheck/TcSigs.hs [new file with mode: 0644]
compiler/typecheck/TcSimplify.hs
compiler/typecheck/TcType.hs
compiler/vectorise/Vectorise/Generic/PData.hs
testsuite/tests/arrows/should_fail/T5380.stderr
testsuite/tests/dependent/should_compile/T11241.stderr
testsuite/tests/deriving/should_fail/T7148.stderr
testsuite/tests/deriving/should_fail/T7148a.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/ghc-api/landmines/landmines.stdout
testsuite/tests/ghci/scripts/Defer02.stderr
testsuite/tests/ghci/scripts/T10248.stderr
testsuite/tests/ghci/scripts/ghci050.stderr
testsuite/tests/indexed-types/should_compile/Simple14.stderr
testsuite/tests/indexed-types/should_fail/GADTwrong1.stderr
testsuite/tests/indexed-types/should_fail/Overlap6.stderr
testsuite/tests/indexed-types/should_fail/SimpleFail5a.stderr
testsuite/tests/indexed-types/should_fail/T2664.stderr
testsuite/tests/indexed-types/should_fail/T3330a.hs
testsuite/tests/indexed-types/should_fail/T3330a.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/T4174.stderr
testsuite/tests/indexed-types/should_fail/T4272.stderr
testsuite/tests/indexed-types/should_fail/T7786.stderr
testsuite/tests/indexed-types/should_fail/T9662.stderr
testsuite/tests/module/mod71.stderr
testsuite/tests/partial-sigs/should_compile/Defaulting2MROff.stderr
testsuite/tests/partial-sigs/should_compile/Defaulting2MROn.stderr
testsuite/tests/partial-sigs/should_compile/Either.stderr
testsuite/tests/partial-sigs/should_compile/EveryNamed.stderr
testsuite/tests/partial-sigs/should_compile/ExprSigLocal.stderr
testsuite/tests/partial-sigs/should_compile/ExtraConstraints3.stderr
testsuite/tests/partial-sigs/should_compile/SimpleGen.stderr
testsuite/tests/partial-sigs/should_compile/SplicesUsed.stderr
testsuite/tests/partial-sigs/should_compile/SuperCls.stderr
testsuite/tests/partial-sigs/should_compile/T10403.stderr
testsuite/tests/partial-sigs/should_compile/T10438.stderr
testsuite/tests/partial-sigs/should_compile/T10519.stderr
testsuite/tests/partial-sigs/should_compile/T11016.stderr
testsuite/tests/partial-sigs/should_compile/T11192.stderr
testsuite/tests/partial-sigs/should_compile/T11339a.hs [new file with mode: 0644]
testsuite/tests/partial-sigs/should_compile/T11339a.stderr [new file with mode: 0644]
testsuite/tests/partial-sigs/should_compile/T11670.hs [new file with mode: 0644]
testsuite/tests/partial-sigs/should_compile/T11670.stderr [new file with mode: 0644]
testsuite/tests/partial-sigs/should_compile/T12033.hs [new file with mode: 0644]
testsuite/tests/partial-sigs/should_compile/T12033.stderr [new file with mode: 0644]
testsuite/tests/partial-sigs/should_compile/Uncurry.stderr
testsuite/tests/partial-sigs/should_compile/UncurryNamed.stderr
testsuite/tests/partial-sigs/should_compile/WarningWildcardInstantiations.stderr
testsuite/tests/partial-sigs/should_compile/all.T
testsuite/tests/partial-sigs/should_fail/Defaulting1MROff.stderr
testsuite/tests/partial-sigs/should_fail/ExtraConstraintsWildcardInExpressionSignature.hs
testsuite/tests/partial-sigs/should_fail/ExtraConstraintsWildcardInExpressionSignature.stderr
testsuite/tests/partial-sigs/should_fail/ExtraConstraintsWildcardNotEnabled.stderr
testsuite/tests/partial-sigs/should_fail/InstantiatedNamedWildcardsInConstraints.stderr
testsuite/tests/partial-sigs/should_fail/NamedExtraConstraintsWildcard.stderr
testsuite/tests/partial-sigs/should_fail/NamedWildcardExplicitForall.stderr
testsuite/tests/partial-sigs/should_fail/NamedWildcardsEnabled.stderr
testsuite/tests/partial-sigs/should_fail/NamedWildcardsNotEnabled.stderr
testsuite/tests/partial-sigs/should_fail/NamedWildcardsNotInMonotype.stderr
testsuite/tests/partial-sigs/should_fail/PartialTypeSignaturesDisabled.stderr
testsuite/tests/partial-sigs/should_fail/PatBind3.stderr
testsuite/tests/partial-sigs/should_fail/T10045.stderr
testsuite/tests/partial-sigs/should_fail/T10615.stderr
testsuite/tests/partial-sigs/should_fail/T10999.stderr
testsuite/tests/partial-sigs/should_fail/T11122.stderr
testsuite/tests/partial-sigs/should_fail/T11976.stderr
testsuite/tests/partial-sigs/should_fail/TidyClash.stderr
testsuite/tests/partial-sigs/should_fail/TidyClash2.stderr
testsuite/tests/partial-sigs/should_fail/WildcardInstantiations.stderr
testsuite/tests/partial-sigs/should_fail/WildcardsInPatternAndExprSig.stderr
testsuite/tests/partial-sigs/should_fail/all.T
testsuite/tests/patsyn/should_fail/T11010.stderr
testsuite/tests/patsyn/should_fail/T11039.stderr
testsuite/tests/patsyn/should_fail/T11667.stderr
testsuite/tests/polykinds/T10503.stderr
testsuite/tests/polykinds/T11399.hs
testsuite/tests/polykinds/T11399.stderr
testsuite/tests/polykinds/T7438.stderr
testsuite/tests/polykinds/T7594.stderr
testsuite/tests/polykinds/T9017.stderr
testsuite/tests/rename/should_fail/rnfail026.stderr
testsuite/tests/th/T10267.stderr
testsuite/tests/typecheck/should_compile/ExPat.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_compile/ExPatFail.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_compile/ExPatFail.stderr [new file with mode: 0644]
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/SigTyVars.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_compile/T10072.stderr
testsuite/tests/typecheck/should_compile/T10632.stderr
testsuite/tests/typecheck/should_compile/T11339.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_compile/T11339.stderr [new file with mode: 0644]
testsuite/tests/typecheck/should_compile/T11339b.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_compile/T11339c.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_compile/T11339d.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_compile/T11700.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_compile/T12069.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_compile/T2357.hs
testsuite/tests/typecheck/should_compile/T2494.stderr
testsuite/tests/typecheck/should_compile/T9834.stderr
testsuite/tests/typecheck/should_compile/T9939.stderr
testsuite/tests/typecheck/should_compile/all.T
testsuite/tests/typecheck/should_compile/holes.stderr
testsuite/tests/typecheck/should_compile/holes3.stderr
testsuite/tests/typecheck/should_compile/tc141.stderr
testsuite/tests/typecheck/should_fail/T10285.stderr
testsuite/tests/typecheck/should_fail/T10534.stderr
testsuite/tests/typecheck/should_fail/T10715.stderr
testsuite/tests/typecheck/should_fail/T11347.stderr
testsuite/tests/typecheck/should_fail/T1899.stderr
testsuite/tests/typecheck/should_fail/T2714.stderr
testsuite/tests/typecheck/should_fail/T3102.stderr
testsuite/tests/typecheck/should_fail/T5691.stderr
testsuite/tests/typecheck/should_fail/T7264.stderr
testsuite/tests/typecheck/should_fail/T7748a.stderr
testsuite/tests/typecheck/should_fail/T7869.stderr
testsuite/tests/typecheck/should_fail/T8450.stderr
testsuite/tests/typecheck/should_fail/T9109.stderr
testsuite/tests/typecheck/should_fail/mc19.stderr
testsuite/tests/typecheck/should_fail/mc21.stderr
testsuite/tests/typecheck/should_fail/mc22.stderr
testsuite/tests/typecheck/should_fail/tcfail032.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/tcfail103.stderr
testsuite/tests/typecheck/should_fail/tcfail131.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/tcfail179.stderr
testsuite/tests/typecheck/should_fail/tcfail191.stderr
testsuite/tests/typecheck/should_fail/tcfail193.stderr
testsuite/tests/typecheck/should_fail/tcfail198.stderr
testsuite/tests/typecheck/should_fail/tcfail201.stderr
testsuite/tests/typecheck/should_fail/tcfail206.stderr