TemplateHaskell with StrictData and -funbox-strict-fields panics
Summary
Compiler panics with the following trivial example.
Steps to reproduce
Only required package is vector-th-unbox
and code is:
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -funbox-strict-fields #-}
import Data.Vector.Unboxed.Deriving (derivingUnbox)
newtype X
= X { unX :: Word }
deriving (Eq, Ord, Show)
data Y = Y
{ yX :: X
, yD :: Double
} deriving (Eq, Show)
derivingUnbox "Y"
[t| Y -> (Word, Double) |]
[| \ y -> (unX (yX y), yD y) |]
[| \ (x, d) -> Y (X x) d |]
main :: IO ()
main = putStrLn "Hello!"
which results in:
ghc: panic! (the 'impossible' happened)
(GHC version 8.6.5 for x86_64-unknown-linux):
mkNewTyConRhs
MV_Y [Int#, MVector s_a5Mc[sk:1] Word, MVector s_a5Mc[sk:1] Double]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable
pprPanic, called at compiler/iface/BuildTyCl.hs:65:27 in ghc:BuildTyCl
Removing the StrictData
language pragma or the -funbox-strict-fields
option allows this to compile.
Expected behavior
This code should panic the compiler.
Environment
- GHC version used: 8.6.5
Optional:
- Operating System: Linux
- System Architecture: x86_64