[GHC] #15738: -ddump-splices omits required parentheses around quantified constraints

GHC ghc-devs at haskell.org
Thu Oct 11 13:47:25 UTC 2018


#15738: -ddump-splices omits required parentheses around quantified constraints
-------------------------------------+-------------------------------------
           Reporter:  RyanGlScott    |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:  8.8.1
          Component:  Template       |           Version:  8.6.1
  Haskell                            |
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 If you compile this program with `-ddump-splices`:

 {{{#!hs
 {-# LANGUAGE QuantifiedConstraints #-}
 {-# LANGUAGE TemplateHaskell #-}
 {-# OPTIONS_GHC -ddump-splices #-}
 module Bug where

 import Language.Haskell.TH

 data Foo x = MkFoo x

 $([d| f :: (forall a. Eq (Foo a)) => Foo x -> Foo x -> Bool
       f = (==)
     |])
 }}}

 You'll notice something fishy:

 {{{
 $ /opt/ghc/8.6.1/bin/ghci Bug.hs
 GHCi, version 8.6.1: http://www.haskell.org/ghc/  :? for help
 Loaded GHCi configuration from /home/rgscott/.ghci
 [1 of 1] Compiling Bug              ( Bug.hs, interpreted )
 Bug.hs:(10,3)-(12,6): Splicing declarations
     [d| f_a1Ia ::
           (forall a_a1Ic. Eq (Foo a_a1Ic)) =>
           Foo x_a1Ib -> Foo x_a1Ib -> Bool
         f_a1Ia = (==) |]
   ======>
     f_a5tj ::
       forall a_a5tk. Eq (Foo a_a5tk) => Foo x_a5ti -> Foo x_a5ti -> Bool
     f_a5tj = (==)
 Ok, one module loaded.
 }}}

 The signature for `f` gets pretty-printed as:

 {{{#!hs
 f_a5tj :: forall a_a5tk. Eq (Foo a_a5tk) => Foo x_a5ti -> Foo x_a5ti ->
 Bool
 }}}

 Which is just plain wrong—there is a missing set of parentheses around the
 quantified constraint `forall a_a5tk. Eq (Foo a_a5tk)`.

 Patch incoming.

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


More information about the ghc-tickets mailing list