[GHC] #15738: -ddump-splices omits required parentheses around quantified constraints
#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
#15738: -ddump-splices omits required parentheses around quantified constraints -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: 8.8.1 Component: Template Haskell | Version: 8.6.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5222 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => patch * differential: => Phab:D5222 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15738#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15738: -ddump-splices omits required parentheses around quantified constraints -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: 8.8.1 Component: Template Haskell | Version: 8.6.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5222 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"02b2116e458357e87718e7378a80579a7021e2a7/ghc" 02b2116/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="02b2116e458357e87718e7378a80579a7021e2a7" Fix #15738 by defining (and using) parenthesizeHsContext With `QuantifiedConstraints`, `forall`s can appear in more nested positions than they could before, but `Convert` and the TH pretty-printer were failing to take this into account. On the `Convert` side, this is fixed by using a `parenthesizeHsContext` to parenthesize singleton quantified constraints that appear to the left of a `=>`. (A similar fix is applied to the TH pretty-printer.) Test Plan: make test TEST=T15738 Reviewers: goldfire, bgamari Reviewed By: bgamari Subscribers: rwbarton, carter GHC Trac Issues: #15738 Differential Revision: https://phabricator.haskell.org/D5222 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15738#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15738: -ddump-splices omits required parentheses around quantified constraints -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.8.1 Component: Template Haskell | Version: 8.6.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5222 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15738#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC