-ddump-splices prints out empty contexts in GADT constructors needlessly
If you compile the following program on HEAD:
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -ddump-splices #-}
module Bug where
$([d| data T where
MkT :: forall a. a -> T
|])
You will get the following -ddump-splices
output:
$ ~/Software/ghc-9.3.20211029/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o, Bug.dyn_o )
Bug.hs:(7,2)-(9,7): Splicing declarations
[d| data T_agC where MkT_agD :: forall a_agE. a_agE -> T_agC |]
======>
data T_a23v where MkT_a23w :: forall a_a23x. () => a_a23x -> T_a23v
Note that it needlessly prints out an empty context in forall a_a23x. () => a_a23x -> T_a23v
. This is a regression, as here is how it is printed in GHC 9.2.1:
$ ghc-9.2.1 Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o, Bug.dyn_o )
Bug.hs:(7,2)-(9,7): Splicing declarations
[d| data T_ag6 where MkT_ag7 :: forall a_ag8. a_ag8 -> T_ag6 |]
======>
data T_a27p where MkT_a27q :: forall a_a27r. a_a27r -> T_a27p
This is likely my fault, as I introduced this buglet in commit 4c87a3d1. The spirit of that commit is correct, but when I introduced the mkHsContextMaybe
function (which determines if a Cxt
should be turned into Just
or Nothing
as a Maybe (LHsContext GhcPs)
), I forgot to use mkHsContextMaybe
in the code that converts data constructor types. The fix is rather simple—patch incoming.