Skip to content

Assertion failure with TypeData + GADTs

(Originally spun off from !9960 (comment 481419))

If you compile the following program with GHC 9.6 when built with assertions enabled + -O:

{-# LANGUAGE TypeData #-}
module B where

type data T a b where
  MkT :: T a a

f :: T a b -> T a b
f x = x

Then it will trigger an assertion failure:

$ ~/Software/ghc3/_build/stage1/bin/ghc -O Bug.hs
[1 of 1] Compiling B                ( Bug.hs, Bug.o ) [Source file changed]

<no location info>: error:
    ASSERT failed!
  CallStack (from HasCallStack):
    assert, called at compiler/GHC/Core/DataCon.hs:1677:23 in ghc:GHC.Core.DataCon

This assertion comes from here:

dataConRepArgTys :: DataCon -> [Scaled Type]
dataConRepArgTys (MkData { dcRep = rep
                         , dcEqSpec = eq_spec
                         , dcOtherTheta = theta
                         , dcOrigArgTys = orig_arg_tys })
  = case rep of
      NoDataConRep -> assert (null eq_spec) $ map unrestricted theta ++ orig_arg_tys
      DCR { dcr_arg_tys = arg_tys } -> arg_tys
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information