diff --git a/compiler/GHC/ThToHs.hs b/compiler/GHC/ThToHs.hs index 8f8f11d672e26aee6a337eb659ac6dad292584e5..96be958fb9b752439c8439e395f74d7e092af449 100644 --- a/compiler/GHC/ThToHs.hs +++ b/compiler/GHC/ThToHs.hs @@ -1485,7 +1485,8 @@ cvtp (ListP ps) = do { ps' <- cvtPats ps ; return $ ListPat noAnn ps'} cvtp (SigP p t) = do { p' <- cvtPat p; t' <- cvtType t - ; return $ SigPat noAnn p' (mkHsPatSigType noAnn t') } + ; let pp = parenthesizePat sigPrec p' + ; return $ SigPat noAnn pp (mkHsPatSigType noAnn t') } cvtp (ViewP e p) = do { e' <- cvtl e; p' <- cvtPat p ; return $ ViewPat noAnn e' p'} cvtp (TypeP t) = do { t' <- cvtType t diff --git a/testsuite/tests/th/T24837.hs b/testsuite/tests/th/T24837.hs new file mode 100644 index 0000000000000000000000000000000000000000..c44c362f3205bc17598603023979b0fb7cdb84b7 --- /dev/null +++ b/testsuite/tests/th/T24837.hs @@ -0,0 +1,6 @@ +{-# LANGUAGE TemplateHaskell #-} +module T24837 where + +import Language.Haskell.TH + +$([d| f ((x :: Bool) :: Bool) = x |]) diff --git a/testsuite/tests/th/T24837.stderr b/testsuite/tests/th/T24837.stderr new file mode 100644 index 0000000000000000000000000000000000000000..3d18269f322dd1eb25e8b25ed880c1dec4dd38ed --- /dev/null +++ b/testsuite/tests/th/T24837.stderr @@ -0,0 +1,4 @@ +T24837.hs:6:2-37: Splicing declarations + [d| f ((x :: Bool) :: Bool) = x |] + ======> + f ((x :: Bool) :: Bool) = x diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T index 269624c2ac3db549cdc0df78ddaeaf8f599ae30e..bda61c4df471645f00026c3fcf5c433e2da1611b 100644 --- a/testsuite/tests/th/all.T +++ b/testsuite/tests/th/all.T @@ -614,3 +614,4 @@ test('T24557d', normal, compile_fail, ['']) test('T24557e', normal, compile, ['']) test('T24702a', normal, compile, ['']) test('T24702b', normal, compile, ['']) +test('T24837', normal, compile, ['-v0 -ddump-splices -dsuppress-uniques'])