Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#10050 closed bug (fixed)

template haskell Ppr missing parentheses for SigT

Reported by: aavogt Owned by:
Priority: normal Milestone: 7.10.1
Component: Compiler Version: 7.8.4
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

ppr (SigE (VarE (mkName "a")) (SigT (VarT (mkName "x")) (VarT (mkName "k"))))

prints as "a :: x :: k". Ghc can't parse that, so I think it should be printed as "a :: (x :: k)"

Change History (5)

comment:1 Changed 5 years ago by adamse

The printing of SigE happens in https://github.com/ghc/ghc/blob/master/libraries/template-haskell/Language/Haskell/TH/Ppr.hs#L172 and SigT happens in https://github.com/ghc/ghc/blob/master/libraries/template-haskell/Language/Haskell/TH/Ppr.hs#L507.

If it is always correct to put parens around a Type :: Kind signature the fix could go in the latter place otherwise pprExp of SigE could inspect the second argument to SigE to see if it is a SigT and only then put parens around it.

What would be the correct solution?

comment:2 Changed 5 years ago by Simon Peyton Jones <simonpj@…>

In 111e5870803bcccd1c0736fdba432f8f9410454f/ghc:

Put parens around (ty :: kind) when pretty-printing TH syntax

See Note [Pretty-printing kind signatures] in Language.Haskell.TH.Ppr.hs,
and Trac #10050.

comment:3 Changed 5 years ago by simonpj

Status: newmerge

Thanks for reporting this.

I have not added a regression test because several existing tests use this syntax.

Last edited 5 years ago by simonpj (previous) (diff)

comment:4 Changed 5 years ago by thoughtpolice

Resolution: fixed
Status: mergeclosed

Merged to ghc-7.10 (via b5f465e247c37e905b25057aa9072c8861058381).

comment:5 Changed 5 years ago by thoughtpolice

Milestone: 7.10.1
Note: See TracTickets for help on using tickets.