diff options
| author | Ryan Scott <ryan.gl.scott@gmail.com> | 2017-05-20 12:56:50 -0400 |
|---|---|---|
| committer | Ben Gamari <ben@smart-cactus.org> | 2017-05-20 16:29:18 -0400 |
| commit | 2108460f9211bf5eab98e0f2f3218dcd271eeaad (patch) | |
| tree | 30a0098830297c198e8e4b2dcc4dc4348c270fdc /compiler/iface | |
| parent | 5b8f95d7fca302a9ad27533b74b1a1c2364605dc (diff) | |
| download | haskell-2108460f9211bf5eab98e0f2f3218dcd271eeaad.tar.gz | |
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: https://phabricator.haskell.org/D3587
Diffstat (limited to 'compiler/iface')
| -rw-r--r-- | compiler/iface/IfaceSyn.hs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/compiler/iface/IfaceSyn.hs b/compiler/iface/IfaceSyn.hs index 338397d22f..60206ea076 100644 --- a/compiler/iface/IfaceSyn.hs +++ b/compiler/iface/IfaceSyn.hs @@ -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 + where + -- 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 |
