From 34d8bc24e33aa373acb6fdeef51427d968f28c0c Mon Sep 17 00:00:00 2001 From: sheaf Date: Tue, 11 Jan 2022 10:42:17 +0100 Subject: Fix parsing & printing of unboxed sums The pretty-printing of partially applied unboxed sums was incorrect, as we incorrectly dropped the first half of the arguments, even for a partial application such as (# | #) @IntRep @DoubleRep Int# which lead to the nonsensical (# DoubleRep | Int# #). This patch also allows users to write unboxed sum type constructors such as (# | #) :: TYPE r1 -> TYPE r2 -> TYPE (SumRep '[r1,r2]). Fixes #20858 and #20859. --- compiler/GHC/Driver/Session.hs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'compiler/GHC/Driver') diff --git a/compiler/GHC/Driver/Session.hs b/compiler/GHC/Driver/Session.hs index b0b37a822c..780a38e3d7 100644 --- a/compiler/GHC/Driver/Session.hs +++ b/compiler/GHC/Driver/Session.hs @@ -3851,6 +3851,10 @@ impliedXFlags , (LangExt.TemplateHaskell, turnOn, LangExt.TemplateHaskellQuotes) , (LangExt.Strict, turnOn, LangExt.StrictData) + -- Historically only UnboxedTuples was required for unboxed sums to work. + -- To avoid breaking code, we make UnboxedTuples imply UnboxedSums. + , (LangExt.UnboxedTuples, turnOn, LangExt.UnboxedSums) + -- The extensions needed to declare an H98 unlifted data type , (LangExt.UnliftedDatatypes, turnOn, LangExt.DataKinds) , (LangExt.UnliftedDatatypes, turnOn, LangExt.StandaloneKindSignatures) -- cgit v1.2.1