Skip to content

TypeApplications error message doesn't parenthesize infix name

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.

Trac metadata
Trac field Value
Version 8.4.3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information