Commit 2108460f authored by Ryan Scott's avatar Ryan Scott Committed by Ben Gamari

Pretty-print strict record fields from ifaces correctly

We need to use parentheses more when pretty-printing types with bang
patterns within constructors that use record syntax. Fixes #13699.

Test Plan: make test TEST=T13699

Reviewers: austin, bgamari, dfeuer

Reviewed By: dfeuer

Subscribers: dfeuer, rwbarton, thomie

GHC Trac Issues: #13699

Differential Revision:
parent 5b8f95d7
......@@ -1003,7 +1003,15 @@ pprIfaceConDecl ss gadt_style tycon tc_binders parent
pprParendIfaceCoercion co
pprParendBangTy (bang, ty) = ppr_bang bang <> pprParendIfaceType ty
pprBangTy (bang, ty) = ppr_bang bang <> ppr ty
pprBangTy (bang, ty) = ppr_bang bang <> ppr_banged_ty ty
-- The presence of bang patterns or UNPACK annotations requires
-- surrounding the type with parentheses, if needed (#13699)
ppr_banged_ty = case bang of
IfNoBang -> ppr
IfStrict -> pprParendIfaceType
IfUnpack -> pprParendIfaceType
IfUnpackCo{} -> pprParendIfaceType
pp_args :: [SDoc] -- With parens, e.g (Maybe a) or !(Maybe a)
pp_args = map pprParendBangTy tys_w_strs
module T13699 where
data Foo = Foo
{ foo1 :: Int
, foo2 :: !Int
, foo3 :: Maybe Int
, foo4 :: !(Maybe Int)
data Bar = Bar Int !Int (Maybe Int) !(Maybe Int)
data Foo
= Foo {foo1 :: Int,
foo2 :: !Int,
foo3 :: Maybe Int,
foo4 :: !(Maybe Int)}
-- Defined at T13699.hs:3:1
data Bar = Bar Int !Int (Maybe Int) !(Maybe Int)
-- Defined at T13699.hs:10:1
......@@ -255,3 +255,4 @@ test('T13420', normal, ghci_script, ['T13420.script'])
test('T13466', normal, ghci_script, ['T13466.script'])
test('GhciCurDir', normal, ghci_script, ['GhciCurDir.script'])
test('T13591', expect_broken(13591), ghci_script, ['T13591.script'])
test('T13699', normal, ghci_script, ['T13699.script'])
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