Unpacking unlifted types without bang
Summary
Making #20187 (comment 369775) into its own issue. Using an unpack pragma on an unlifted type without a bang pattern causes a warning.
Steps to reproduce
Compile this code:
{-# LANGUAGE StandaloneKindSignatures, MagicHash, DataKinds, UnliftedDatatypes #-}
module Test where
import GHC.Exts
import GHC.Types
type IntU :: UnliftedType
data IntU = IntU Int#
data Test = Test {-# UNPACK #-} IntU
It produces the warning:
U.hs:11:13: warning:
• UNPACK pragma lacks '!' on the first argument of ‘Test’
• In the definition of data constructor ‘Test’
In the data type declaration for ‘Test’
|
11 | data Test = Test {-# UNPACK #-} IntU
| ^^^^^^^^^^^^^^^^^^^^^^^^
Expected behavior
I expected it to compile without warnings and also perform the unpacking. By the way, what is the easiest way to check if the unpacking actually happens?
Environment
- GHC version used: 9.3.20210504