diff options
author | Krzysztof Gogolewski <krz.gogolewski@gmail.com> | 2014-09-18 14:52:50 -0700 |
---|---|---|
committer | Edward Z. Yang <ezyang@cs.stanford.edu> | 2014-09-18 14:53:46 -0700 |
commit | 275dcafbfb6b371dd5d8943fa4df9c23e68f6165 (patch) | |
tree | 11edf1e79c8879fd836549531d3be0f2825a5108 /compiler/rename/RnSource.lhs | |
parent | ed58ec059c3a3d6f550f42b2707e59f851b8f90d (diff) | |
download | haskell-275dcafbfb6b371dd5d8943fa4df9c23e68f6165.tar.gz |
Add -fwarn-context-quantification (#4426)
Summary:
This warning (enabled by default) reports places where a context
implicitly binds a type variable, for example
type T a = {-forall m.-} Monad m => a -> m a
Also update Haddock submodule.
Test Plan: validate
Reviewers: hvr, goldfire, simonpj, austin
Reviewed By: austin
Subscribers: simonmar, ezyang, carter
Differential Revision: https://phabricator.haskell.org/D211
GHC Trac Issues: #4426
Diffstat (limited to 'compiler/rename/RnSource.lhs')
-rw-r--r-- | compiler/rename/RnSource.lhs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/compiler/rename/RnSource.lhs b/compiler/rename/RnSource.lhs index 2dc71db001..4af8be32fd 100644 --- a/compiler/rename/RnSource.lhs +++ b/compiler/rename/RnSource.lhs @@ -1286,8 +1286,13 @@ rnConDecl decl@(ConDecl { con_name = name, con_qvars = tvs -- With an Explicit forall, check for unused binders -- With Implicit, find the mentioned ones, and use them as binders + -- With Qualified, do the same as with Implicit, but give a warning + -- See Note [Context quantification] ; new_tvs <- case expl of Implicit -> return (mkHsQTvs (userHsTyVarBndrs loc free_tvs)) + Qualified -> do { warnContextQuantification (docOfHsDocContext doc) + (userHsTyVarBndrs loc free_tvs) + ; return (mkHsQTvs (userHsTyVarBndrs loc free_tvs)) } Explicit -> do { warnUnusedForAlls (docOfHsDocContext doc) tvs free_tvs ; return tvs } @@ -1471,10 +1476,10 @@ add gp loc (SpliceD splice@(SpliceDecl _ flag)) ds = do { -- We've found a top-level splice. If it is an *implicit* one -- (i.e. a naked top level expression) case flag of - Explicit -> return () - Implicit -> do { th_on <- xoptM Opt_TemplateHaskell - ; unless th_on $ setSrcSpan loc $ - failWith badImplicitSplice } + ExplicitSplice -> return () + ImplicitSplice -> do { th_on <- xoptM Opt_TemplateHaskell + ; unless th_on $ setSrcSpan loc $ + failWith badImplicitSplice } ; return (gp, Just (splice, ds)) } where |