Commit 07afe448 authored by Simon Peyton Jones's avatar Simon Peyton Jones
Browse files

Remove the check_lifted check in TcValidity

This patch fixes Trac #11465.  The check_unlifted check really isn't
necessary, as discussed in Trac #11120 comment:19.

Removing it made just one test-suite change,
in indexed-types/should_fail/T9357, by allowing

   type family F (a :: k1) :: k2
   type instance F Int# = Int

to be accepted.  And indeed that seems entirely reasonable.
parent b3ee37ce
......@@ -430,9 +430,21 @@ forAllAllowed _ = False
----------------------------------------
-- | Fail with error message if the type is unlifted
check_lifted :: TidyEnv -> Type -> TcM ()
check_lifted _ _ = return ()
{- ------ Legacy comment ---------
The check_unlifted function seems entirely redundant. The
kind system should check for uses of unlifted types. So I've
removed the check. See Trac #11120 comment:19.
check_lifted env ty
= checkTcM (not (isUnLiftedType ty)) (unliftedArgErr env ty)
unliftedArgErr :: TidyEnv -> Type -> (TidyEnv, SDoc)
unliftedArgErr env ty = (env, sep [text "Illegal unlifted type:", ppr_tidy env ty])
------ End of legacy comment --------- -}
check_type :: TidyEnv -> UserTypeCtxt -> Rank -> Type -> TcM ()
-- The args say what the *type context* requires, independent
-- of *flag* settings. You test the flag settings at usage sites.
......@@ -598,9 +610,8 @@ forAllEscapeErr env ty tau_kind
2 (vcat [ text " type:" <+> ppr_tidy env ty
, text "of kind:" <+> ppr_tidy env tau_kind ]) )
unliftedArgErr, ubxArgTyErr :: TidyEnv -> Type -> (TidyEnv, SDoc)
unliftedArgErr env ty = (env, sep [text "Illegal unlifted type:", ppr_tidy env ty])
ubxArgTyErr env ty = (env, sep [text "Illegal unboxed tuple type as function argument:", ppr_tidy env ty])
ubxArgTyErr :: TidyEnv -> Type -> (TidyEnv, SDoc)
ubxArgTyErr env ty = (env, sep [text "Illegal unboxed tuple type as function argument:", ppr_tidy env ty])
kindErr :: TidyEnv -> Kind -> (TidyEnv, SDoc)
kindErr env kind = (env, sep [text "Expecting an ordinary type, but found a type of kind", ppr_tidy env kind])
......
......@@ -4,5 +4,10 @@ module T9357 where
import GHC.Exts
type family F (a :: k1) :: k2
type instance F Int# = Int
-- This one is actually OK (F is poly-kinded;
-- c.f. Trac #11120 comment:19
type instance F (forall a. a->a) = Int
-- But this one is not (impredicative)
T9357.hs:7:15:
Illegal unlifted type: Int#
In the type instance declaration for ‘F’
T9357.hs:8:15:
Illegal polymorphic or qualified type: forall a1. a1 -> a1
In the type instance declaration for ‘F’
T9357.hs:12:15: error:
• Illegal polymorphic or qualified type: forall a1. a1 -> a1
• In the type instance declaration for ‘F’
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment