Commit 32008a9d authored by Ryan Scott's avatar Ryan Scott Committed by Krzysztof Gogolewski

Properly designate LambdaCase alts as CaseAlt in TH

Summary:
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`
consistently.

Test Plan: make test TEST=T15518

Reviewers: goldfire, bgamari

Subscribers: rwbarton, carter

GHC Trac Issues: #15518

Differential Revision: https://phabricator.haskell.org/D5069
parent bd48a88c
......@@ -829,7 +829,7 @@ cvtl e = wrapL (cvt e)
; return $ HsLam noExt (mkMatchGroup FromSource
[mkSimpleMatch LambdaExpr
pats e'])}
cvt (LamCaseE ms) = do { ms' <- mapM (cvtMatch LambdaExpr) ms
cvt (LamCaseE ms) = do { ms' <- mapM (cvtMatch CaseAlt) ms
; return $ HsLamCase noExt
(mkMatchGroup FromSource ms')
}
......
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE TemplateHaskell #-}
module T15518 where
$([d| f :: Bool -> ()
f = \case True -> ()
False -> ()
|])
T15518.hs:(5,3)-(8,6): Splicing declarations
[d| f :: Bool -> ()
f = \case
True -> ()
False -> () |]
======>
f :: Bool -> ()
f = \case
True -> ()
False -> ()
......@@ -425,3 +425,4 @@ test('T14471', normal, compile, [''])
test('TH_rebindableAdo', normal, compile, [''])
test('T14627', normal, compile_fail, [''])
test('TH_invalid_add_top_decl', normal, compile_fail, [''])
test('T15518', normal, compile, ['-v0 -ddump-splices -dsuppress-uniques'])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment