diff options
-rw-r--r-- | compiler/hsSyn/HsDecls.hs | 4 | ||||
-rw-r--r-- | testsuite/tests/printer/Makefile | 4 | ||||
-rw-r--r-- | testsuite/tests/printer/T14306.hs | 10 | ||||
-rw-r--r-- | testsuite/tests/printer/all.T | 1 |
4 files changed, 19 insertions, 0 deletions
diff --git a/compiler/hsSyn/HsDecls.hs b/compiler/hsSyn/HsDecls.hs index ecb11a08d6..35fccd3396 100644 --- a/compiler/hsSyn/HsDecls.hs +++ b/compiler/hsSyn/HsDecls.hs @@ -695,6 +695,10 @@ pp_vanilla_decl_head thing (HsQTvs { hsq_explicit = tyvars }) fixity context = hsep [pprHsContext context, pp_tyvars tyvars] where 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)] diff --git a/testsuite/tests/printer/Makefile b/testsuite/tests/printer/Makefile index 1c2f2995d0..4565e83b4d 100644 --- a/testsuite/tests/printer/Makefile +++ b/testsuite/tests/printer/Makefile @@ -213,3 +213,7 @@ T13550: .PHONY: T13942 T13942: $(CHECK_PPR) "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`" T13942.hs + +.PHONY: T14306 +T14306: + $(CHECK_PPR) "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`" T14306.hs diff --git a/testsuite/tests/printer/T14306.hs b/testsuite/tests/printer/T14306.hs new file mode 100644 index 0000000000..c39807e4d3 --- /dev/null +++ b/testsuite/tests/printer/T14306.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE MultiParamTypeClasses #-} +module T14306 where + +class (a `C` b) c + +class (a `D` b) c d + +class (a `E` b) + +class a `F` b diff --git a/testsuite/tests/printer/all.T b/testsuite/tests/printer/all.T index a71d6e3534..9a1170ec0a 100644 --- a/testsuite/tests/printer/all.T +++ b/testsuite/tests/printer/all.T @@ -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']) |