Commit 0e968126 authored by Alan Zimmerman's avatar Alan Zimmerman

Pretty-printer missing parens for infix class declaration

    class (a `C` b) c

Is pretty printed as

    class a `C` b c

Fixes #14306
parent 11a59de2
......@@ -695,6 +695,10 @@ pp_vanilla_decl_head thing (HsQTvs { hsq_explicit = tyvars }) fixity context
= hsep [pprHsContext context, pp_tyvars tyvars]
pp_tyvars (varl:varsr)
| fixity == Infix && length varsr > 1
= hsep [char '(',ppr (unLoc varl), pprInfixOcc (unLoc thing)
, (ppr.unLoc) (head varsr), char ')'
, hsep (map (ppr.unLoc) (tail varsr))]
| fixity == Infix
= hsep [ppr (unLoc varl), pprInfixOcc (unLoc thing)
, hsep (map (ppr.unLoc) varsr)]
......@@ -213,3 +213,7 @@ T13550:
.PHONY: T13942
$(CHECK_PPR) "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`" T13942.hs
.PHONY: T14306
$(CHECK_PPR) "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`" T14306.hs
{-# LANGUAGE MultiParamTypeClasses #-}
module T14306 where
class (a `C` b) c
class (a `D` b) c d
class (a `E` b)
class a `F` b
......@@ -50,3 +50,4 @@ test('T13199', ignore_stderr, run_command, ['$MAKE -s --no-print-directory T1319
test('T13050p', ignore_stderr, run_command, ['$MAKE -s --no-print-directory T13050p'])
test('T13550', ignore_stderr, run_command, ['$MAKE -s --no-print-directory T13550'])
test('T13942', ignore_stderr, run_command, ['$MAKE -s --no-print-directory T13942'])
test('T14306', ignore_stderr, run_command, ['$MAKE -s --no-print-directory T14306'])
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