[GHC] #16059: checkValidType is defeated by a type synonym

GHC ghc-devs at haskell.org
Mon Dec 17 03:12:19 UTC 2018


#16059: checkValidType is defeated by a type synonym
-------------------------------------+-------------------------------------
           Reporter:  RyanGlScott    |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:  8.8.1
          Component:  Compiler       |           Version:  8.7
  (Type checker)                     |
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  GHC accepts
  Unknown/Multiple                   |  invalid program
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 GHC throws an error message on this code:

 {{{#!hs
 {-# LANGUAGE DataKinds #-}
 {-# LANGUAGE PolyKinds #-}
 {-# LANGUAGE RankNTypes #-}
 module Bug where

 f :: forall b (a :: Eq b => b). Int
 f = 42
 }}}
 {{{
 $ ~/Software/ghc/inplace/bin/ghc-stage2 --interactive Bug.hs
 GHCi, version 8.7.20181211: http://www.haskell.org/ghc/  :? for help
 Loaded GHCi configuration from /home/rgscott/.ghci
 [1 of 1] Compiling Bug              ( Bug.hs, interpreted )

 Bug.hs:6:6: error:
     • Illegal constraint in a kind: Eq b => b
     • In the type signature: f :: forall b (a :: Eq b => b). Int
   |
 6 | f :: forall b (a :: Eq b => b). Int
   |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 }}}

 However, it does //not// throw an error message if you hide `Eq b => b`
 behind a type synonym, as the following variant of the code above is
 accepted:

 {{{#!hs
 {-# LANGUAGE DataKinds #-}
 {-# LANGUAGE PolyKinds #-}
 {-# LANGUAGE RankNTypes #-}
 module Bug where

 type Foo b = Eq b => b

 f :: forall b (a :: Foo b). Int
 f = 42
 }}}

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/16059>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list