summaryrefslogtreecommitdiff
path: root/compiler/GHC/Hs
diff options
context:
space:
mode:
authorAndrei Borzenkov <andreyborzenkov2002@gmail.com>2023-01-17 17:22:54 +0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2023-01-18 22:26:43 -0500
commit14b5982a3aea351e4b01c5804ebd4d4629ba6bab (patch)
treeef1fd598914a6625b90c28cc71cb7041c03cc823 /compiler/GHC/Hs
parent154889dbfbef62ad58a28df4171bf767cc690c2a (diff)
downloadhaskell-14b5982a3aea351e4b01c5804ebd4d4629ba6bab.tar.gz
Fix printing of promoted MkSolo datacon (#22785)
Problem: In 2463df2f, the Solo data constructor was renamed to MkSolo, and Solo was turned into a pattern synonym for backwards compatibility. Since pattern synonyms can not be promoted, the old code that pretty-printed promoted single-element tuples started producing ill-typed code: t :: Proxy ('Solo Int) This fails with "Pattern synonym ‘Solo’ used as a type" The solution is to track the distinction between type constructors and data constructors more carefully when printing single-element tuples.
Diffstat (limited to 'compiler/GHC/Hs')
-rw-r--r--compiler/GHC/Hs/Expr.hs2
-rw-r--r--compiler/GHC/Hs/Pat.hs2
-rw-r--r--compiler/GHC/Hs/Type.hs8
3 files changed, 6 insertions, 6 deletions
diff --git a/compiler/GHC/Hs/Expr.hs b/compiler/GHC/Hs/Expr.hs
index ed0280cb18..31d67c308c 100644
--- a/compiler/GHC/Hs/Expr.hs
+++ b/compiler/GHC/Hs/Expr.hs
@@ -545,7 +545,7 @@ ppr_expr (SectionR _ op expr)
ppr_expr (ExplicitTuple _ exprs boxity)
-- Special-case unary boxed tuples so that they are pretty-printed as
- -- `Solo x`, not `(x)`
+ -- `MkSolo x`, not `(x)`
| [Present _ expr] <- exprs
, Boxed <- boxity
= hsep [text (mkTupleStr Boxed dataName 1), ppr expr]
diff --git a/compiler/GHC/Hs/Pat.hs b/compiler/GHC/Hs/Pat.hs
index 39a788aab5..bc0b51457e 100644
--- a/compiler/GHC/Hs/Pat.hs
+++ b/compiler/GHC/Hs/Pat.hs
@@ -350,7 +350,7 @@ pprPat (SigPat _ pat ty) = ppr pat <+> dcolon <+> ppr ty
pprPat (ListPat _ pats) = brackets (interpp'SP pats)
pprPat (TuplePat _ pats bx)
-- Special-case unary boxed tuples so that they are pretty-printed as
- -- `Solo x`, not `(x)`
+ -- `MkSolo x`, not `(x)`
| [pat] <- pats
, Boxed <- bx
= hcat [text (mkTupleStr Boxed dataName 1), pprParendLPat appPrec pat]
diff --git a/compiler/GHC/Hs/Type.hs b/compiler/GHC/Hs/Type.hs
index 053042d4a1..313b8e8fe2 100644
--- a/compiler/GHC/Hs/Type.hs
+++ b/compiler/GHC/Hs/Type.hs
@@ -104,7 +104,7 @@ import GHC.Parser.Annotation
import GHC.Types.Fixity ( LexicalFixity(..) )
import GHC.Types.Id ( Id )
import GHC.Types.SourceText
-import GHC.Types.Name( Name, NamedThing(getName), tcName )
+import GHC.Types.Name( Name, NamedThing(getName), tcName, dataName )
import GHC.Types.Name.Reader ( RdrName )
import GHC.Types.Var ( VarBndr, visArgTypeLike )
import GHC.Core.TyCo.Rep ( Type(..) )
@@ -1170,9 +1170,9 @@ ppr_mono_ty (HsExplicitListTy _ prom tys)
| otherwise = brackets (interpp'SP tys)
ppr_mono_ty (HsExplicitTupleTy _ tys)
-- Special-case unary boxed tuples so that they are pretty-printed as
- -- `'Solo x`, not `'(x)`
+ -- `'MkSolo x`, not `'(x)`
| [ty] <- tys
- = quote $ sep [text (mkTupleStr Boxed tcName 1), ppr_mono_lty ty]
+ = quote $ sep [text (mkTupleStr Boxed dataName 1), ppr_mono_lty ty]
| otherwise
= quote $ parens (maybeAddSpace tys $ interpp'SP tys)
ppr_mono_ty (HsTyLit _ t) = ppr t
@@ -1235,7 +1235,7 @@ hsTypeNeedsParens p = go_hs_ty
go_hs_ty (HsSpliceTy{}) = False
go_hs_ty (HsExplicitListTy{}) = False
-- Special-case unary boxed tuple applications so that they are
- -- parenthesized as `Proxy ('Solo x)`, not `Proxy 'Solo x` (#18612)
+ -- parenthesized as `Proxy ('MkSolo x)`, not `Proxy 'MkSolo x` (#18612)
-- See Note [One-tuples] in GHC.Builtin.Types
go_hs_ty (HsExplicitTupleTy _ [_])
= p >= appPrec