Representation-polymorphic unboxed sum causes a panic
The existing representation-polymorphism checks allow some unboxed sums to slip through the cracks:
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE UnboxedTuples #-}
module RepPolySum where
import GHC.Exts
baz :: forall (rep :: RuntimeRep) (a :: TYPE rep). () -> (# Int# | a #)
baz _ = (# 17# | #)
ghc: panic! (the 'impossible' happened)
(GHC version 9.0.1:
runtimeRepPrimRep
typePrimRep (a_aCt :: TYPE rep_aCs)
rep_aCs
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler\GHC\Utils\Outputable.hs:1230:37 in ghc:GHC.Utils.Outputable
pprPanic, called at compiler\\GHC\\Types\\RepType.hs:527:5 in ghc:GHC.Types.RepType
(That's with GHC 9.0; the same error exists on HEAD.)
It wouldn't be hard to fix with the existing mechanisms (in the desugarer), but I'm currently fixing it in the typechecker as part of !6164 (closed).