[GHC] #14331: Overzealous free-floating kind check causes deriving clause to be rejected

GHC ghc-devs at haskell.org
Thu Oct 12 12:34:11 UTC 2017


#14331: Overzealous free-floating kind check causes deriving clause to be rejected
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  merge
        Priority:  normal            |            Milestone:  8.2.2
       Component:  Compiler (Type    |              Version:  8.2.1
  checker)                           |
      Resolution:                    |             Keywords:  deriving
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  GHC rejects       |            Test Case:
  valid program                      |  deriving/should_compile/T14331
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by RyanGlScott):

 I still don't think this is quite right. Look at what happens now when you
 try to compile this variation of the original program:

 {{{#!hs
 {-# LANGUAGE DeriveAnyClass #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
 {-# LANGUAGE PolyKinds #-}
 module Bug where

 class C a b

 data D a = D deriving (C (a :: k))
 }}}
 {{{
 GHCi, version 8.3.20171011: http://www.haskell.org/ghc/  :? for help
 Loaded GHCi configuration from /home/rgscott/.ghci
 [1 of 1] Compiling Bug              ( Bug.hs, interpreted )

 Bug.hs:8:27: error:
     • Expected kind ‘k1’, but ‘a’ has kind ‘k’
     • In the first argument of ‘C’, namely ‘(a :: k)’
       In the data declaration for ‘D’
   |
 8 | data D a = D deriving (C (a :: k))
   |                           ^
 }}}

 This is wrong—the `a` in `D a` and `C a` should have the same kind, since
 they're the same `a`.

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


More information about the ghc-tickets mailing list