#15518 closed bug (fixed)

-ddump-splices pretty-prints LambdaCase nonsensically

Reported by: RyanGlScott Owned by:
Priority: normal Milestone: 8.6.1
Component: Template Haskell Version: 8.4.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D5069
Wiki Page:


{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -ddump-splices #-}
module Bug where

$([d| f :: Bool -> ()
      f = \case True  -> ()
                False -> ()
$ /opt/ghc/8.4.3/bin/ghci Bug.hs
GHCi, version 8.4.3: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/ryanglscott/.ghci
[1 of 1] Compiling Bug              ( Bug.hs, interpreted )
Bug.hs:(6,3)-(9,6): Splicing declarations
    [d| f_a1xr :: Bool -> ()
          = \case
              True -> ()
              False -> () |]
    f_a48E :: Bool -> ()
      = \case
          \ True -> GHC.Tuple.()
          \ False -> GHC.Tuple.()
Ok, one module loaded.

Notice the use of \ True and \ False. Those patterns should not be preceded with backslashes.

Change History (5)

comment:1 Changed 13 months ago by RyanGlScott

Differential Rev(s): Phab:D5069
Status: newpatch

comment:2 Changed 13 months ago by Krzysztof Gogolewski <krz.gogolewski@…>

In 32008a9d/ghc:

Properly designate LambdaCase alts as CaseAlt in TH

When `\case` expressions are parsed normally, their
alternatives are marked as `CaseAlt` (which means that they are
pretty-printed without a `\` character in front of them, unlike for
lambda expressions). However, `\case` expressions created by way of
Template Haskell (in `Convert`) inconsistently designated the case
alternatives as `LambdaExpr`, causing them to be pretty-printed
poorly (as shown in #15518). The fix is simple: use `CaseAlt`

Test Plan: make test TEST=T15518

Reviewers: goldfire, bgamari

Subscribers: rwbarton, carter

GHC Trac Issues: #15518

Differential Revision: https://phabricator.haskell.org/D5069

comment:3 Changed 13 months ago by monoidal

Status: patchmerge

comment:4 Changed 13 months ago by RyanGlScott


This was marked as merge, but not milestoned properly.

comment:5 Changed 13 months ago by bgamari

Resolution: fixed
Status: mergeclosed
Note: See TracTickets for help on using tickets.