From 275dcafbfb6b371dd5d8943fa4df9c23e68f6165 Mon Sep 17 00:00:00 2001 From: Krzysztof Gogolewski Date: Thu, 18 Sep 2014 14:52:50 -0700 Subject: 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 --- compiler/rename/RnSource.lhs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'compiler/rename/RnSource.lhs') 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 -- cgit v1.2.1