Skip to content

Calling a function that pattern matches on unlifted type in GHCi produces segmentation fault

Summary

Directly calling a function that pattern matches on an Unlifted type which has at least two constructors in GHCi results in a segfault.

Both pattern matching directly in GHCi, as well as calling a function which calls another function that does the pattern matching, works fine.

This looks similar but is different from #19628 (closed).

Steps to reproduce

{-# LANGUAGE UnliftedDatatypes, StandaloneKindSignatures #-}

import GHC.Exts

type C :: UnliftedType
data C = A | B

foo A = ()

main = print $ foo A

In GHCi:

ghci> main              -- this works fine
()
ghci> case A of A -> () -- as does this
()
ghci> foo A
Segmentation fault (core dumped)

Expected behavior

Same behavior as main.

Environment

  • GHC version used: 9.3.20210802

Optional:

  • Operating System: Arch Linux
  • System Architecture: x86_64
Edited by Jakob Brünker
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information