diff options
author | Richard Eisenberg <rae@richarde.dev> | 2021-01-04 11:07:00 -0500 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-01-09 21:19:45 -0500 |
commit | c8c63dde01686a96af4dabcced78110368efaec3 (patch) | |
tree | b8801ecd61c343c18cf05fee157886e37554b244 /testsuite/tests/typecheck/should_fail | |
parent | f88fb8c7d803f9d3bf245fa4bd9c50f7a2bd3c5b (diff) | |
download | haskell-c8c63dde01686a96af4dabcced78110368efaec3.tar.gz |
Never Anyify during kind inference
See Note [Error on unconstrained meta-variables] in TcMType.
Close #17301
Close #17567
Close #17562
Close #15474
Diffstat (limited to 'testsuite/tests/typecheck/should_fail')
11 files changed, 113 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_fail/T15474.hs b/testsuite/tests/typecheck/should_fail/T15474.hs new file mode 100644 index 0000000000..2fb68e8020 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T15474.hs @@ -0,0 +1,15 @@ +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeInType #-} +module T15474 where + +import Data.Kind (Type) + +data Proxy a + +type Forall = forall t. Proxy t + +f1 :: forall (t :: Type). Proxy t +f1 = f1 + +f2 :: Forall +f2 = f1 diff --git a/testsuite/tests/typecheck/should_fail/T15474.stderr b/testsuite/tests/typecheck/should_fail/T15474.stderr new file mode 100644 index 0000000000..7fd96ebaa1 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T15474.stderr @@ -0,0 +1,5 @@ + +T15474.hs:9:1: error: + • Uninferrable type variable k0 in + the type synonym right-hand side: forall (t :: k0). Proxy @{k0} t + • In the type declaration for ‘Forall’ diff --git a/testsuite/tests/typecheck/should_fail/T17301.hs b/testsuite/tests/typecheck/should_fail/T17301.hs new file mode 100644 index 0000000000..2fdaace98b --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T17301.hs @@ -0,0 +1,36 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE UndecidableInstances #-} + +module T17301 where + +import GHC.TypeLits + ( TypeError, ErrorMessage(..) ) + +data A = MkA +data B (a :: A) + +data TySing ty where + SB :: TySing (B a) + +data ATySing where + MkATySing :: TySing ty -> ATySing + +type family Forget ty :: ATySing where + Forget (B a) = MkATySing SB + +type family Message ty where + Message (MkATySing (_ :: TySing ty)) = + TypeError ( ShowType ty ) + + + +type KnownType = B MkA + +foo :: Message (Forget KnownType) => () +foo = () + +bar :: () +bar = foo diff --git a/testsuite/tests/typecheck/should_fail/T17301.stderr b/testsuite/tests/typecheck/should_fail/T17301.stderr new file mode 100644 index 0000000000..7c7e20f005 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T17301.stderr @@ -0,0 +1,5 @@ + +T17301.hs:22:3: error: + • Uninferrable type variable (a0 :: A) in + type family equation right-hand side: 'MkATySing @(B a0) ('SB @a0) + • In the type family declaration for ‘Forget’ diff --git a/testsuite/tests/typecheck/should_fail/T17562.hs b/testsuite/tests/typecheck/should_fail/T17562.hs new file mode 100644 index 0000000000..a758a8cfe6 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T17562.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE QuantifiedConstraints, MultiParamTypeClasses, PolyKinds #-} +-- NB: PolyKinds. This is actually accepted with -XNoPolyKinds because of defaulting. +-- See T17562b for the NoPolyKinds case. + +module T17562 where + +class (forall a. a b ~ a c) => C b c diff --git a/testsuite/tests/typecheck/should_fail/T17562.stderr b/testsuite/tests/typecheck/should_fail/T17562.stderr new file mode 100644 index 0000000000..22086bdd0d --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T17562.stderr @@ -0,0 +1,5 @@ + +T17562.hs:7:1: error: + • Uninferrable type variable k0 in + the class context: forall (a :: k -> k0). (a b :: k0) ~ (a c :: k0) + • In the class declaration for ‘C’ diff --git a/testsuite/tests/typecheck/should_fail/T17567.hs b/testsuite/tests/typecheck/should_fail/T17567.hs new file mode 100644 index 0000000000..2ea82aae13 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T17567.hs @@ -0,0 +1,15 @@ +{-# LANGUAGE PolyKinds, RankNTypes #-} + +module T17567 where + +import Data.Proxy + +type T = forall a. Proxy a + +p :: T +p = Proxy + +x :: Proxy a -> a +x = undefined + +y = x p diff --git a/testsuite/tests/typecheck/should_fail/T17567.stderr b/testsuite/tests/typecheck/should_fail/T17567.stderr new file mode 100644 index 0000000000..75b4de2960 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T17567.stderr @@ -0,0 +1,5 @@ + +T17567.hs:7:1: error: + • Uninferrable type variable k0 in + the type synonym right-hand side: forall (a :: k0). Proxy @{k0} a + • In the type declaration for ‘T’ diff --git a/testsuite/tests/typecheck/should_fail/T17567StupidTheta.hs b/testsuite/tests/typecheck/should_fail/T17567StupidTheta.hs new file mode 100644 index 0000000000..a023c0f7f8 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T17567StupidTheta.hs @@ -0,0 +1,6 @@ +{-# LANGUAGE QuantifiedConstraints, DatatypeContexts, PolyKinds #-} +-- NB: This actually works with -XNoPolyKinds, due to defaulting. + +module T17567StupidTheta where + +data (forall a. a b ~ a c) => T b c diff --git a/testsuite/tests/typecheck/should_fail/T17567StupidTheta.stderr b/testsuite/tests/typecheck/should_fail/T17567StupidTheta.stderr new file mode 100644 index 0000000000..7ae2b35ab8 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T17567StupidTheta.stderr @@ -0,0 +1,9 @@ + +T17567StupidTheta.hs:1:37: warning: + -XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language. + +T17567StupidTheta.hs:6:1: error: + • Uninferrable type variable k0 in + the datatype context: + forall (a :: k -> k0). (a b :: k0) ~ (a c :: k0) + • In the data declaration for ‘T’ diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T index e92404fbc5..c9318dd18f 100644 --- a/testsuite/tests/typecheck/should_fail/all.T +++ b/testsuite/tests/typecheck/should_fail/all.T @@ -578,6 +578,11 @@ test('ExplicitSpecificity10', normal, compile_fail, ['']) test('T18357', normal, compile_fail, ['']) test('T18357a', normal, compile_fail, ['']) test('T18357b', normal, compile_fail, ['']) +test('T17301', normal, compile_fail, ['']) +test('T17567', normal, compile_fail, ['']) +test('T17562', normal, compile_fail, ['']) +test('T17567StupidTheta', normal, compile_fail, ['']) +test('T15474', normal, compile_fail, ['']) test('T18455', normal, compile_fail, ['']) test('T18534', normal, compile_fail, ['']) test('T18714', normal, compile_fail, ['']) |