#15527 closed bug (fixed)

TypeApplications error message doesn't parenthesize infix name

Reported by: RyanGlScott Owned by:
Priority: normal Milestone: 8.6.1
Component: Compiler Version: 8.4.3
Keywords: TypeApplications Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Poor/confusing error message Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D5071
Wiki Page:


If you compile the following program:

module Bug where

f :: (Int -> Int) -> (Int -> Int) -> (Int -> Int)
f =  (.) @Int

You'll get this error:

$ /opt/ghc/8.4.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug              ( Bug.hs, Bug.o )

Bug.hs:4:6: error:
    Pattern syntax in expression context: .@Int
    Did you mean to enable TypeApplications?
4 | f =  (.) @Int
  |      ^^^^^^^^

I was taken aback by this strange .@ thing before I realized what was actually going on: the error message simply forgot to parenthesize .. This is ppr_expr's fault, since it calls ppr on an RdrName instead of pprPrefixOcc. Patch incoming.

Change History (4)

comment:1 Changed 13 months ago by RyanGlScott

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

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

In 5238f204/ghc:

Fix #15527 by pretty-printing an RdrName prefixly

When `(.) @Int` is used without enabling `TypeApplications`,
the resulting error message will pretty-print the (symbolic)
`RdrName` `(.)`. However, it does so without parenthesizing it, which
causes the pretty-printed expression to appear as `.@Int`. Yuck.

Since the expression in a type application will always be prefix,
we can fix this issue by using `pprPrefixOcc` instead of plain ol'

Test Plan: make test TEST=T15527

Reviewers: bgamari, monoidal, simonpj

Reviewed By: monoidal, simonpj

Subscribers: rwbarton, carter

GHC Trac Issues: #15527

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

comment:3 Changed 13 months ago by monoidal

Status: patchmerge

comment:4 Changed 13 months ago by bgamari

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