diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2016-04-20 12:56:40 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2016-04-20 14:28:34 +0100 |
commit | 353d8ae6fafe117a1cac4adf6f029a5baccc2780 (patch) | |
tree | 9a55b083e597b0d2d614639a54c85b0119384bd2 /testsuite/tests | |
parent | 7319b80a2cdffdfac8586946d0c7b0fdc8d77dae (diff) | |
download | haskell-353d8ae6fafe117a1cac4adf6f029a5baccc2780.tar.gz |
SCC analysis for instances as well as types/classes
This big patch is in pursuit of Trac #11348.
It is largely the work of Alex Veith (thank you!), with some
follow-up simplification and refactoring from Simon PJ.
The main payload is described in RnSource
Note [Dependency analysis of type, class, and instance decls]
which is pretty detailed.
* There is a new data type HsDecls.TyClGroup, for a strongly
connected component of type/class/instance/role decls.
The hs_instds field of HsGroup disappears, in consequence
This forces some knock-on changes, including a minor
haddock submodule update
Smaller, weakly-related things
* I found that both the renamer and typechecker were building an
identical env for RoleAnnots, so I put common code for
RoleAnnotEnv in RnEnv.
* I found that tcInstDecls1 had very clumsy error handling, so I
put it together into TcInstDcls.doClsInstErrorChecks
Diffstat (limited to 'testsuite/tests')
-rw-r--r-- | testsuite/tests/deriving/should_fail/T9687.stderr | 6 | ||||
-rw-r--r-- | testsuite/tests/driver/sigof02/Map.hsig | 1 | ||||
-rw-r--r-- | testsuite/tests/ghci/scripts/T4175.stdout | 112 | ||||
-rw-r--r-- | testsuite/tests/indexed-types/should_fail/T8550.stderr | 21 | ||||
-rw-r--r-- | testsuite/tests/polykinds/T8132.stderr | 5 | ||||
-rw-r--r-- | testsuite/tests/rename/should_compile/T4003A.hs-boot | 1 | ||||
-rw-r--r-- | testsuite/tests/roles/should_compile/T8958.stderr | 2 | ||||
-rw-r--r-- | testsuite/tests/th/T1835.stdout | 6 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_compile/T11348.hs | 18 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_compile/all.T | 1 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_fail/T6018fail.stderr | 6 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_fail/tcfail211.stderr | 16 |
12 files changed, 111 insertions, 84 deletions
diff --git a/testsuite/tests/deriving/should_fail/T9687.stderr b/testsuite/tests/deriving/should_fail/T9687.stderr index 36425e48c8..a98f775bee 100644 --- a/testsuite/tests/deriving/should_fail/T9687.stderr +++ b/testsuite/tests/deriving/should_fail/T9687.stderr @@ -1,3 +1,5 @@ -T9687.hs:4:10: error: - Class ‘Typeable’ does not support user-specified instances +T9687.hs:4:1: error: + • Class ‘Typeable’ does not support user-specified instances + • In the instance declaration for + ‘Typeable (a, b, c, d, e, f, g, h)’ diff --git a/testsuite/tests/driver/sigof02/Map.hsig b/testsuite/tests/driver/sigof02/Map.hsig index cd094df17f..8e46f1d63f 100644 --- a/testsuite/tests/driver/sigof02/Map.hsig +++ b/testsuite/tests/driver/sigof02/Map.hsig @@ -14,7 +14,6 @@ infixl 9 !,\\ type role Map nominal representational data Map k a -instance Typeable Map instance Functor (Map k) instance Foldable (Map k) instance Traversable (Map k) diff --git a/testsuite/tests/ghci/scripts/T4175.stdout b/testsuite/tests/ghci/scripts/T4175.stdout index d319bd630e..f76feb6194 100644 --- a/testsuite/tests/ghci/scripts/T4175.stdout +++ b/testsuite/tests/ghci/scripts/T4175.stdout @@ -1,56 +1,56 @@ -type family A a b :: * -- Defined at T4175.hs:7:1
-type instance A (B a) b = () -- Defined at T4175.hs:10:15
-type instance A (Maybe a) a = a -- Defined at T4175.hs:9:15
-type instance A Int Int = () -- Defined at T4175.hs:8:15
-data family B a -- Defined at T4175.hs:12:1
-instance G B -- Defined at T4175.hs:34:10
-data instance B () = MkB -- Defined at T4175.hs:13:15
-type instance A (B a) b = () -- Defined at T4175.hs:10:15
-class C a where
- type family D a b :: *
- -- Defined at T4175.hs:16:5
-type instance D () a = Bool -- Defined at T4175.hs:22:10
-type instance D Int b = String -- Defined at T4175.hs:19:10
-type family E a :: *
- where
- E () = Bool
- E Int = String
- -- Defined at T4175.hs:24:1
-data () = () -- Defined in ‘GHC.Tuple’
-instance C () -- Defined at T4175.hs:21:10
-instance Bounded () -- Defined in ‘GHC.Enum’
-instance Enum () -- Defined in ‘GHC.Enum’
-instance Eq () -- Defined in ‘GHC.Classes’
-instance Ord () -- Defined in ‘GHC.Classes’
-instance Read () -- Defined in ‘GHC.Read’
-instance Show () -- Defined in ‘GHC.Show’
-instance Monoid () -- Defined in ‘GHC.Base’
-type instance D () a = Bool -- Defined at T4175.hs:22:10
-data instance B () = MkB -- Defined at T4175.hs:13:15
-data Maybe a = Nothing | Just a -- Defined in ‘GHC.Base’
-instance Eq a => Eq (Maybe a) -- Defined in ‘GHC.Base’
-instance Monad Maybe -- Defined in ‘GHC.Base’
-instance Functor Maybe -- Defined in ‘GHC.Base’
-instance Ord a => Ord (Maybe a) -- Defined in ‘GHC.Base’
-instance Read a => Read (Maybe a) -- Defined in ‘GHC.Read’
-instance Show a => Show (Maybe a) -- Defined in ‘GHC.Show’
-instance Applicative Maybe -- Defined in ‘GHC.Base’
-instance Foldable Maybe -- Defined in ‘Data.Foldable’
-instance Traversable Maybe -- Defined in ‘Data.Traversable’
-instance Monoid a => Monoid (Maybe a) -- Defined in ‘GHC.Base’
-type instance A (Maybe a) a = a -- Defined at T4175.hs:9:15
-data Int = I# Int# -- Defined in ‘GHC.Types’
-instance C Int -- Defined at T4175.hs:18:10
-instance Bounded Int -- Defined in ‘GHC.Enum’
-instance Enum Int -- Defined in ‘GHC.Enum’
-instance Eq Int -- Defined in ‘GHC.Classes’
-instance Integral Int -- Defined in ‘GHC.Real’
-instance Num Int -- Defined in ‘GHC.Num’
-instance Ord Int -- Defined in ‘GHC.Classes’
-instance Read Int -- Defined in ‘GHC.Read’
-instance Real Int -- Defined in ‘GHC.Real’
-instance Show Int -- Defined in ‘GHC.Show’
-type instance D Int b = String -- Defined at T4175.hs:19:10
-type instance A Int Int = () -- Defined at T4175.hs:8:15
-class Z a -- Defined at T4175.hs:28:1
-instance F (Z a) -- Defined at T4175.hs:31:10
+type family A a b :: * -- Defined at T4175.hs:7:1 +type instance A (Maybe a) a = a -- Defined at T4175.hs:9:15 +type instance A Int Int = () -- Defined at T4175.hs:8:15 +type instance A (B a) b = () -- Defined at T4175.hs:10:15 +data family B a -- Defined at T4175.hs:12:1 +instance G B -- Defined at T4175.hs:34:10 +data instance B () = MkB -- Defined at T4175.hs:13:15 +type instance A (B a) b = () -- Defined at T4175.hs:10:15 +class C a where + type family D a b :: * + -- Defined at T4175.hs:16:5 +type instance D () a = Bool -- Defined at T4175.hs:22:10 +type instance D Int b = String -- Defined at T4175.hs:19:10 +type family E a :: * + where + E () = Bool + E Int = String + -- Defined at T4175.hs:24:1 +data () = () -- Defined in ‘GHC.Tuple’ +instance C () -- Defined at T4175.hs:21:10 +instance Bounded () -- Defined in ‘GHC.Enum’ +instance Enum () -- Defined in ‘GHC.Enum’ +instance Eq () -- Defined in ‘GHC.Classes’ +instance Ord () -- Defined in ‘GHC.Classes’ +instance Read () -- Defined in ‘GHC.Read’ +instance Show () -- Defined in ‘GHC.Show’ +instance Monoid () -- Defined in ‘GHC.Base’ +type instance D () a = Bool -- Defined at T4175.hs:22:10 +data instance B () = MkB -- Defined at T4175.hs:13:15 +data Maybe a = Nothing | Just a -- Defined in ‘GHC.Base’ +instance Eq a => Eq (Maybe a) -- Defined in ‘GHC.Base’ +instance Monad Maybe -- Defined in ‘GHC.Base’ +instance Functor Maybe -- Defined in ‘GHC.Base’ +instance Ord a => Ord (Maybe a) -- Defined in ‘GHC.Base’ +instance Read a => Read (Maybe a) -- Defined in ‘GHC.Read’ +instance Show a => Show (Maybe a) -- Defined in ‘GHC.Show’ +instance Applicative Maybe -- Defined in ‘GHC.Base’ +instance Foldable Maybe -- Defined in ‘Data.Foldable’ +instance Traversable Maybe -- Defined in ‘Data.Traversable’ +instance Monoid a => Monoid (Maybe a) -- Defined in ‘GHC.Base’ +type instance A (Maybe a) a = a -- Defined at T4175.hs:9:15 +data Int = I# Int# -- Defined in ‘GHC.Types’ +instance C Int -- Defined at T4175.hs:18:10 +instance Bounded Int -- Defined in ‘GHC.Enum’ +instance Enum Int -- Defined in ‘GHC.Enum’ +instance Eq Int -- Defined in ‘GHC.Classes’ +instance Integral Int -- Defined in ‘GHC.Real’ +instance Num Int -- Defined in ‘GHC.Num’ +instance Ord Int -- Defined in ‘GHC.Classes’ +instance Read Int -- Defined in ‘GHC.Read’ +instance Real Int -- Defined in ‘GHC.Real’ +instance Show Int -- Defined in ‘GHC.Show’ +type instance D Int b = String -- Defined at T4175.hs:19:10 +type instance A Int Int = () -- Defined at T4175.hs:8:15 +class Z a -- Defined at T4175.hs:28:1 +instance F (Z a) -- Defined at T4175.hs:31:10 diff --git a/testsuite/tests/indexed-types/should_fail/T8550.stderr b/testsuite/tests/indexed-types/should_fail/T8550.stderr index 1092ed247d..fb37303bce 100644 --- a/testsuite/tests/indexed-types/should_fail/T8550.stderr +++ b/testsuite/tests/indexed-types/should_fail/T8550.stderr @@ -1,11 +1,12 @@ -T8550.hs:13:12: - Reduction stack overflow; size = 201 - When simplifying the following type: F () - Use -freduction-depth=0 to disable this check - (any upper bound you could choose might fail unpredictably with - minor updates to GHC, so disabling the check is recommended if - you're sure that type checking should terminate) - In the expression: A - In the expression: seq A (return ()) - In an equation for ‘main’: main = seq A (return ()) +T8550.hs:8:3: error: + • Reduction stack overflow; size = 201 + When simplifying the following type: F () + Use -freduction-depth=0 to disable this check + (any upper bound you could choose might fail unpredictably with + minor updates to GHC, so disabling the check is recommended if + you're sure that type checking should terminate) + • In the ambiguity check for ‘A’ + To defer the ambiguity check to use sites, enable AllowAmbiguousTypes + In the definition of data constructor ‘A’ + In the data type declaration for ‘A’ diff --git a/testsuite/tests/polykinds/T8132.stderr b/testsuite/tests/polykinds/T8132.stderr index 4a1ca2b4f6..c5f56f9fbe 100644 --- a/testsuite/tests/polykinds/T8132.stderr +++ b/testsuite/tests/polykinds/T8132.stderr @@ -1,3 +1,4 @@ -T8132.hs:6:10: error: - Class ‘Typeable’ does not support user-specified instances +T8132.hs:6:1: error: + • Class ‘Typeable’ does not support user-specified instances + • In the instance declaration for ‘Typeable K’ diff --git a/testsuite/tests/rename/should_compile/T4003A.hs-boot b/testsuite/tests/rename/should_compile/T4003A.hs-boot index a615301e57..04902ddc62 100644 --- a/testsuite/tests/rename/should_compile/T4003A.hs-boot +++ b/testsuite/tests/rename/should_compile/T4003A.hs-boot @@ -4,5 +4,4 @@ import Data.Data data HsExpr i -instance Typeable HsExpr instance Data i => Data (HsExpr i) diff --git a/testsuite/tests/roles/should_compile/T8958.stderr b/testsuite/tests/roles/should_compile/T8958.stderr index f88557eafc..982686868f 100644 --- a/testsuite/tests/roles/should_compile/T8958.stderr +++ b/testsuite/tests/roles/should_compile/T8958.stderr @@ -12,9 +12,9 @@ TYPE CONSTRUCTORS COERCION AXIOMS axiom T8958.N:Map :: Map k v = [(k, v)] -- Defined at T8958.hs:13:1 INSTANCES - instance [incoherent] Nominal a -- Defined at T8958.hs:7:10 instance [incoherent] Representational a -- Defined at T8958.hs:10:10 + instance [incoherent] Nominal a -- Defined at T8958.hs:7:10 Dependent modules: [] Dependent packages: [base-4.9.0.0, ghc-prim-0.5.0.0, integer-gmp-1.0.0.1] diff --git a/testsuite/tests/th/T1835.stdout b/testsuite/tests/th/T1835.stdout index 5b21c0352c..7d34ae01f0 100644 --- a/testsuite/tests/th/T1835.stdout +++ b/testsuite/tests/th/T1835.stdout @@ -1,8 +1,8 @@ class GHC.Classes.Eq a_0 => Main.MyClass (a_0 :: *) -instance Main.MyClass Main.Foo +instance GHC.Classes.Ord a_1 => Main.MyClass (Main.Quux2 a_1) +instance GHC.Classes.Eq a_2 => Main.MyClass (Main.Quux a_2) instance Main.MyClass Main.Baz -instance GHC.Classes.Eq a_1 => Main.MyClass (Main.Quux a_1) -instance GHC.Classes.Ord a_2 => Main.MyClass (Main.Quux2 a_2) +instance Main.MyClass Main.Foo True True True diff --git a/testsuite/tests/typecheck/should_compile/T11348.hs b/testsuite/tests/typecheck/should_compile/T11348.hs new file mode 100644 index 0000000000..2548dbdab7 --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T11348.hs @@ -0,0 +1,18 @@ +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE TypeInType #-} + +module T11348 where + +import Data.Kind +import Data.Proxy + +type family TrivialFamily t :: Type +type instance TrivialFamily (t :: Type) = Bool + +data R where + R :: Proxy Bool -> R + +type ProblemType t = 'R ('Proxy :: Proxy (TrivialFamily t)) diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T index 8046fa34fc..ebc68eb941 100644 --- a/testsuite/tests/typecheck/should_compile/all.T +++ b/testsuite/tests/typecheck/should_compile/all.T @@ -513,3 +513,4 @@ test('T11512', normal, compile, ['']) test('T11754', normal, compile, ['']) test('T11811', normal, compile, ['']) test('T11793', normal, compile, ['']) +test('T11348', normal, compile, ['']) diff --git a/testsuite/tests/typecheck/should_fail/T6018fail.stderr b/testsuite/tests/typecheck/should_fail/T6018fail.stderr index 95b9d1bb3e..c20c9ecc89 100644 --- a/testsuite/tests/typecheck/should_fail/T6018fail.stderr +++ b/testsuite/tests/typecheck/should_fail/T6018fail.stderr @@ -62,7 +62,7 @@ T6018fail.hs:59:10: error: (i.e. ones independent of the class type variables) must be distinct type variables Expected: PolyKindVarsF '[] - Actual: PolyKindVarsF '[] + Actual: PolyKindVarsF '[] Use -fprint-explicit-kinds to see the kind arguments • In the type instance declaration for ‘PolyKindVarsF’ In the instance declaration for ‘PolyKindVarsC '[]’ @@ -91,10 +91,10 @@ T6018fail.hs:70:15: error: forall k (a :: k) (b :: k). Gc a b = Int -- Defined at T6018fail.hs:70:15 -T6018fail.hs:75:15: error: +T6018fail.hs:74:15: error: Type family equations violate injectivity annotation: - F1 (Maybe a) = Maybe (GF2 a) -- Defined at T6018fail.hs:75:15 F1 [a] = Maybe (GF1 a) -- Defined at T6018fail.hs:74:15 + F1 (Maybe a) = Maybe (GF2 a) -- Defined at T6018fail.hs:75:15 T6018fail.hs:87:15: error: Type family equation violates injectivity annotation. diff --git a/testsuite/tests/typecheck/should_fail/tcfail211.stderr b/testsuite/tests/typecheck/should_fail/tcfail211.stderr index 614aaf59fa..7a5053a092 100644 --- a/testsuite/tests/typecheck/should_fail/tcfail211.stderr +++ b/testsuite/tests/typecheck/should_fail/tcfail211.stderr @@ -1,6 +1,12 @@ -tcfail211.hs:5:1: - Illegal implicit parameter ‘?imp::Int’ - In the context: ?imp::Int - While checking the super-classes of class ‘D’ - In the class declaration for ‘D’ +tcfail211.hs:5:1: error: + • Illegal implicit parameter ‘?imp::Int’ + • In the context: ?imp::Int + While checking the super-classes of class ‘D’ + In the class declaration for ‘D’ + +tcfail211.hs:8:10: error: + • Illegal implicit parameter ‘?imp::Int’ + • In the context: ?imp::Int + While checking an instance declaration + In the instance declaration for ‘D Int’ |