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 /testsuite | |
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 'testsuite')
-rw-r--r-- | testsuite/tests/rename/should_compile/T4426.hs | 22 | ||||
-rw-r--r-- | testsuite/tests/rename/should_compile/T4426.stderr | 35 | ||||
-rw-r--r-- | testsuite/tests/rename/should_compile/all.T | 1 | ||||
-rw-r--r-- | testsuite/tests/th/T7021a.hs | 4 | ||||
-rw-r--r-- | testsuite/tests/th/T8807.hs | 6 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_compile/T3018.hs | 4 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_compile/tc092.hs | 2 |
7 files changed, 66 insertions, 8 deletions
diff --git a/testsuite/tests/rename/should_compile/T4426.hs b/testsuite/tests/rename/should_compile/T4426.hs new file mode 100644 index 0000000000..b04f59cd03 --- /dev/null +++ b/testsuite/tests/rename/should_compile/T4426.hs @@ -0,0 +1,22 @@ +{-# LANGUAGE RankNTypes #-} +{-# OPTIONS_GHC -fwarn-context-quantification #-} + +module T4426 where + +type F a = Monad m => a -> m a + +data X a = X (Eq b => a -> b) + +data Y a = Y { k :: Eq b => a -> b -> c } + +f :: forall b. (Monad m => m b) -> b +f = undefined + +type F' a = forall m. Monad m => a -> m a + +data X' a = X' (forall b. Eq b => a -> b) + +data Y' a = Y' { k' :: forall b c. Eq b => a -> b -> c } + +f' :: forall b. (forall m. Monad m => m b) -> b +f' = undefined diff --git a/testsuite/tests/rename/should_compile/T4426.stderr b/testsuite/tests/rename/should_compile/T4426.stderr new file mode 100644 index 0000000000..f4e0c471d6 --- /dev/null +++ b/testsuite/tests/rename/should_compile/T4426.stderr @@ -0,0 +1,35 @@ + +T4426.hs:6:12: Warning: + Variable ‘m’ is implicitly quantified due to a context + Use explicit forall syntax instead. + This will become an error in GHC 7.12. + In the type ‘Monad m => a -> m a’ + In the declaration for type synonym ‘F’ + +T4426.hs:8:15: Warning: + Variable ‘b’ is implicitly quantified due to a context + Use explicit forall syntax instead. + This will become an error in GHC 7.12. + In the type ‘Eq b => a -> b’ + In the definition of data constructor ‘X’ + +T4426.hs:10:21: Warning: + Variable ‘b’ is implicitly quantified due to a context + Use explicit forall syntax instead. + This will become an error in GHC 7.12. + In the type ‘Eq b => a -> b -> c’ + In the definition of data constructor ‘Y’ + +T4426.hs:10:21: Warning: + Variable ‘c’ is implicitly quantified due to a context + Use explicit forall syntax instead. + This will become an error in GHC 7.12. + In the type ‘Eq b => a -> b -> c’ + In the definition of data constructor ‘Y’ + +T4426.hs:12:17: Warning: + Variable ‘m’ is implicitly quantified due to a context + Use explicit forall syntax instead. + This will become an error in GHC 7.12. + In the type ‘Monad m => m b’ + In the type signature for ‘f’ diff --git a/testsuite/tests/rename/should_compile/all.T b/testsuite/tests/rename/should_compile/all.T index d104df4910..7185fba5b8 100644 --- a/testsuite/tests/rename/should_compile/all.T +++ b/testsuite/tests/rename/should_compile/all.T @@ -217,3 +217,4 @@ test('T7969', run_command, ['$MAKE -s --no-print-directory T7969']) test('T9127', normal, compile, ['']) +test('T4426', normal, compile, ['']) diff --git a/testsuite/tests/th/T7021a.hs b/testsuite/tests/th/T7021a.hs index bd191336dd..0eadecf4c6 100644 --- a/testsuite/tests/th/T7021a.hs +++ b/testsuite/tests/th/T7021a.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE ConstraintKinds, TemplateHaskell, PolyKinds, TypeFamilies #-} +{-# LANGUAGE ConstraintKinds, TemplateHaskell, PolyKinds, TypeFamilies, RankNTypes #-} module T7021a where @@ -27,5 +27,5 @@ test = do reify fooName reify bazName reify barName - [t| (Show a, (Read a, Num a)) => a -> a |] + [t| forall a. (Show a, (Read a, Num a)) => a -> a |] [| \_ -> 0 |] diff --git a/testsuite/tests/th/T8807.hs b/testsuite/tests/th/T8807.hs index 3090123f95..7d21796298 100644 --- a/testsuite/tests/th/T8807.hs +++ b/testsuite/tests/th/T8807.hs @@ -1,8 +1,8 @@ -{-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE ConstraintKinds, RankNTypes #-} module T8807 where import Data.Proxy -foo :: $( [t| a b => Proxy a -> b -> b |] ) -foo = undefined
\ No newline at end of file +foo :: $( [t| forall a b. a b => Proxy a -> b -> b |] ) +foo = undefined diff --git a/testsuite/tests/typecheck/should_compile/T3018.hs b/testsuite/tests/typecheck/should_compile/T3018.hs index 443d73a17a..296185de30 100644 --- a/testsuite/tests/typecheck/should_compile/T3018.hs +++ b/testsuite/tests/typecheck/should_compile/T3018.hs @@ -20,7 +20,7 @@ class Sat a where dict :: a class Subst_A a t t' where subst_A :: (Monad m) => a -> t -> t' -> m t' -data SubstD_A a t t' = SubstD_A {substD_A:: (Monad m) => a -> t -> t' -> m t'} +data SubstD_A a t t' = SubstD_A {substD_A:: forall m. (Monad m) => a -> t -> t' -> m t'} -- Allow override dictionary verion with implementation of type class Subst instance Subst_A a t t' => Sat (SubstD_A a t t') where @@ -103,4 +103,4 @@ constraints, and only makes the attempt when it has all the evidence in hand. I'm thinking quite a bit about constraint solving at the moment and will bear that in mind. But I can't offer you an immediate solution. At least I hope I've explained the problem. --}
\ No newline at end of file +-} diff --git a/testsuite/tests/typecheck/should_compile/tc092.hs b/testsuite/tests/typecheck/should_compile/tc092.hs index b421809b8f..58493c6715 100644 --- a/testsuite/tests/typecheck/should_compile/tc092.hs +++ b/testsuite/tests/typecheck/should_compile/tc092.hs @@ -2,7 +2,7 @@ module ShouldSucceed where -data Empty q = Empty (Ord a => q a) +data Empty q = Empty (forall a. Ord a => q a) q :: (Ord a) => [a] q = [] e0, e1, e2 :: Empty [] |