-ddump-splices pretty-printing oddities with case statements
The latest installment in "Ryan finds minor bugs in -ddump-splices". Take this program:
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -ddump-splices #-}
module Bug where
$([d| f :: Bool -> Bool
f x = case x of
(True :: Bool) -> True
(False :: Bool) -> False
g :: Bool -> Bool
g x = (case x of
True -> True
False -> False) :: Bool
|])
Compiling this gives:
$ /opt/ghc/8.2.2/bin/ghci Bug.hs
GHCi, version 8.2.2: 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,3)-(15,6): Splicing declarations
[d| f_a1sB :: Bool -> Bool
f_a1sB x_a1sD
= case x_a1sD of
(True :: Bool) -> True
(False :: Bool) -> False
g_a1sC :: Bool -> Bool
g_a1sC x_a1sE
= (case x_a1sE of
True -> True
False -> False) ::
Bool |]
======>
f_a49Z :: Bool -> Bool
f_a49Z x_a4a0
= case x_a4a0 of
True :: Bool -> True
False :: Bool -> False
g_a49Y :: Bool -> Bool
g_a49Y x_a4a1
= case x_a4a1 of
True -> True
False -> False ::
Bool
Neither the -ddump-splices output for f nor g parse are legal Haskell:
- In
f, GHC fails to parenthesize the pattern signaturesTrue :: BoolandFalse :: Bool. - In
g, GHC fails to parenthesize thecaseexpression which has an explicitBoolsignature.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 8.2.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |