summaryrefslogtreecommitdiff
path: root/compiler/rename
diff options
context:
space:
mode:
authorVladislav Zavialov <vlad.z.4096@gmail.com>2018-06-16 23:44:39 -0400
committerBen Gamari <ben@smart-cactus.org>2018-06-16 23:44:57 -0400
commit8df24474d0194d28b8273c1539af05793156e23f (patch)
treeeeeaf190edb831e45fb23af1960213b530637794 /compiler/rename
parent4cd552184cbc5bed33da21497537df4e400a1a2f (diff)
downloadhaskell-8df24474d0194d28b8273c1539af05793156e23f.tar.gz
Warn about implicit kind variables with -Wcompat
According to an accepted proposal https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/002 4-no-kind-vars.rst With -Wcompat, warn if a kind variable is brought into scope implicitly in a type with an explicit forall. This applies to type signatures and to other contexts that allow a forall with the forall-or-nothing rule in effect (for example, class instances). Test Plan: Validate Reviewers: goldfire, hvr, bgamari, RyanGlScott Reviewed By: goldfire Subscribers: RyanGlScott, rwbarton, thomie, carter GHC Trac Issues: #15264 Differential Revision: https://phabricator.haskell.org/D4834
Diffstat (limited to 'compiler/rename')
-rw-r--r--compiler/rename/RnTypes.hs15
1 files changed, 15 insertions, 0 deletions
diff --git a/compiler/rename/RnTypes.hs b/compiler/rename/RnTypes.hs
index 3d60a9f6c3..ca4986f050 100644
--- a/compiler/rename/RnTypes.hs
+++ b/compiler/rename/RnTypes.hs
@@ -334,6 +334,11 @@ rnImplicitBndrs bind_free_tvs
; traceRn "rnImplicitBndrs" (vcat [ ppr kvs, ppr tvs, ppr real_tvs ])
+ ; whenWOptM Opt_WarnImplicitKindVars $
+ unless (bind_free_tvs || null kvs) $
+ addWarnAt (Reason Opt_WarnImplicitKindVars) (getLoc (head kvs)) $
+ implicit_kind_vars_msg kvs
+
; loc <- getSrcSpanM
; vars <- mapM (newLocalBndrRn . L loc . unLoc) (kvs ++ real_tvs)
@@ -343,6 +348,16 @@ rnImplicitBndrs bind_free_tvs
; bindLocalNamesFV vars $
thing_inside vars }
+ where
+ implicit_kind_vars_msg kvs =
+ vcat [ text "An explicit" <+> quotes (text "forall") <+>
+ text "was used, but the following kind variables" <+>
+ text "are not quantified:" <+>
+ hsep (punctuate comma (map (quotes . ppr) kvs))
+ , text "Despite this fact, GHC will introduce them into scope," <+>
+ text "but it will stop doing so in the future."
+ , text "Suggested fix: add" <+>
+ quotes (text "forall" <+> hsep (map ppr kvs) <> char '.') ]
rnLHsInstType :: SDoc -> LHsSigType GhcPs -> RnM (LHsSigType GhcRn, FreeVars)
-- Rename the type in an instance.