Commit 5238f204 authored by Ryan Scott's avatar Ryan Scott Committed by Krzysztof Gogolewski

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:
parent 7a63f753
......@@ -1087,7 +1087,7 @@ ppr_expr (ArithSeq _ _ info) = brackets (ppr info)
ppr_expr (EWildPat _) = char '_'
ppr_expr (ELazyPat _ e) = char '~' <> ppr e
ppr_expr (EAsPat _ v e) = ppr v <> char '@' <> ppr e
ppr_expr (EAsPat _ (L _ v) e) = pprPrefixOcc v <> char '@' <> ppr e
ppr_expr (EViewPat _ p e) = ppr p <+> text "->" <+> ppr e
ppr_expr (HsSCC _ st (StringLiteral stl lbl) expr)
module T15527 where
f :: (Int -> Int) -> (Int -> Int) -> (Int -> Int)
f = (.) @Int
T15527.hs:4:6: error:
Pattern syntax in expression context: (.)@Int
Did you mean to enable TypeApplications?
......@@ -478,3 +478,4 @@ test('T15330', normal, compile_fail, [''])
test('T15361', normal, compile_fail, [''])
test('T15438', normal, compile_fail, [''])
test('T15523', normal, compile_fail, ['-O'])
test('T15527', normal, compile_fail, [''])
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