Skip to content

TypeData produces missing symbols when defining lifted GADT

Summary

Defining a non-trivial GADT using type data produces linker errors.

Steps to reproduce

Try it here: https://play-haskell.tomsmeding.com/saved/KwkjSb4w (use GHC 9.6.0.20230128)

-- a.hs
{-# LANGUAGE TypeData #-}
module Main where

type data T a where
  A :: T Int
  B :: T a
  
main = return ()
$ ghc-9.6.0.20230128 a.hs
[1 of 2] Compiling Main             ( a.hs, a.o )
[2 of 2] Linking a
a.o(.data+0x0): error: undefined reference to 'Main_A_con_info'
collect2: error: ld returned 1 exit status
ghc-9.6.0.20230128: `gcc' failed in phase `Linker'. (Exit code: 1)

Changing Int to a makes the linker error disappear. Also, changing the a in the type of B to e.g. Bool yields two "undefined reference" linker errors.

Changing type data to data also makes it work.

Expected behavior

Not give linker errors when writing innocuous code.

Environment

  • GHC version used: 9.6.0.20230128

Optional:

  • Operating System: Ubuntu
  • System Architecture: x86_64
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information