[GHC] #13677: Incorrect parenthesization of type in error message

GHC ghc-devs at haskell.org
Tue May 9 22:19:57 UTC 2017


#13677: Incorrect parenthesization of type in error message
-------------------------------------+-------------------------------------
           Reporter:  RyanGlScott    |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.0.1
  (Type checker)                     |
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  Poor/confusing
  Unknown/Multiple                   |  error message
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 If you compile this program:

 {{{#!hs
 {-# LANGUAGE ConstraintKinds #-}
 {-# LANGUAGE GADTs #-}

 import GHC.Exts (Constraint)

 data Dict a where
   Dict :: a => Dict a

 foo :: Dict (Int ~ Int) => Int
 foo = undefined
 }}}

 In GHC 8.0.1, 8.0.2, 8.2.1, or HEAD, it will give this error message:

 {{{
 GHCi, version 8.3.20170509: http://www.haskell.org/ghc/  :? for help
 Loaded GHCi configuration from /home/rgscott/.ghci
 [1 of 1] Compiling Main             ( Bug2.hs, interpreted )

 Bug2.hs:9:8: error:
     • Expected a constraint, but ‘Dict Int ~ Int’ has kind ‘*’
     • In the type signature: foo :: Dict (Int ~ Int) => Int
   |
 9 | foo :: Dict (Int ~ Int) => Int
   |        ^^^^^^^^^^^^^^^^
 }}}

 But `Dict Int ~ Int` is not parenthesized correctly!

 This is a regression, as GHC 7.10.3 and earlier parenthesize it correctly:

 {{{
 GHCi, version 7.10.3: http://www.haskell.org/ghc/  :? for help
 [1 of 1] Compiling Main             ( Bug2.hs, interpreted )

 Bug2.hs:9:8:
     Expected a constraint, but ‘Dict (Int ~ Int)’ has kind ‘*’
     In the type signature for ‘foo’: foo :: Dict (Int ~ Int) => Int
 }}}

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


More information about the ghc-tickets mailing list