diff options
| author | Simon Peyton Jones <simonpj@microsoft.com> | 2020-07-16 14:35:42 +0100 |
|---|---|---|
| committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-09-24 13:16:32 -0400 |
| commit | 9fa26aa16f9eee0b56b5d9e65c16367d7b789996 (patch) | |
| tree | a7b27876018129d93bdb3e91f7b1762e30e37f5b /compiler/GHC/Tc/Module.hs | |
| parent | 97cff9190d346c3b51c32c88fd145fcf1e6678f1 (diff) | |
| download | haskell-9fa26aa16f9eee0b56b5d9e65c16367d7b789996.tar.gz | |
Improve kind generalisation, error messages
This patch does two things:
* It refactors GHC.Tc.Errors a bit. In debugging Quick Look I was
forced to look in detail at error messages, and ended up doing a bit
of refactoring, esp in mkTyVarEqErr'. It's still quite a mess, but
a bit better, I think.
* It makes a significant improvement to the kind checking of type and
class declarations. Specifically, we now ensure that if kind
checking fails with an unsolved constraint, all the skolems are in
scope. That wasn't the case before, which led to some obscure error
messages; and occasional failures with "no skolem info" (eg #16245).
Both of these, and the main Quick Look patch itself, affect a /lot/ of
error messages, as you can see from the number of files changed. I've
checked them all; I think they are as good or better than before.
Smaller things
* I documented the various instances of VarBndr better.
See Note [The VarBndr tyep and its uses] in GHC.Types.Var
* Renamed GHC.Tc.Solver.simpl_top to simplifyTopWanteds
* A bit of refactoring in bindExplicitTKTele, to avoid the
footwork with Either. Simpler now.
* Move promoteTyVar from GHC.Tc.Solver to GHC.Tc.Utils.TcMType
Fixes #16245 (comment 211369), memorialised as
typecheck/polykinds/T16245a
Also fixes the three bugs in #18640
Diffstat (limited to 'compiler/GHC/Tc/Module.hs')
| -rw-r--r-- | compiler/GHC/Tc/Module.hs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/compiler/GHC/Tc/Module.hs b/compiler/GHC/Tc/Module.hs index f29378122c..784625f3a2 100644 --- a/compiler/GHC/Tc/Module.hs +++ b/compiler/GHC/Tc/Module.hs @@ -2589,18 +2589,18 @@ tcRnType hsc_env flexi normalise rdr_type -- It can have any rank or kind -- First bring into scope any wildcards ; traceTc "tcRnType" (vcat [ppr wcs, ppr rn_type]) - ; (ty, kind) <- pushTcLevelM_ $ - -- must push level to satisfy level precondition of - -- kindGeneralize, below - solveEqualities $ - tcNamedWildCardBinders wcs $ \ wcs' -> - do { mapM_ emitNamedTypeHole wcs' - ; tcInferLHsTypeUnsaturated rn_type } + ; (_tclvl, wanted, (ty, kind)) + <- pushLevelAndSolveEqualitiesX "tcRnType" $ + tcNamedWildCardBinders wcs $ \ wcs' -> + do { mapM_ emitNamedTypeHole wcs' + ; tcInferLHsTypeUnsaturated rn_type } + + ; checkNoErrs (reportAllUnsolved wanted) -- Do kind generalisation; see Note [Kind-generalise in tcRnType] ; kvs <- kindGeneralizeAll kind - ; e <- mkEmptyZonkEnv flexi + ; e <- mkEmptyZonkEnv flexi ; ty <- zonkTcTypeToTypeX e ty -- Do validity checking on type @@ -2615,6 +2615,7 @@ tcRnType hsc_env flexi normalise rdr_type ; return (ty', mkInfForAllTys kvs (tcTypeKind ty')) } + {- Note [TcRnExprMode] ~~~~~~~~~~~~~~~~~~~~~~ How should we infer a type when a user asks for the type of an expression e |
