diff options
Diffstat (limited to 'testsuite/tests/ghci/should_run/T22958b.hs')
-rw-r--r-- | testsuite/tests/ghci/should_run/T22958b.hs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/testsuite/tests/ghci/should_run/T22958b.hs b/testsuite/tests/ghci/should_run/T22958b.hs new file mode 100644 index 0000000000..da849286aa --- /dev/null +++ b/testsuite/tests/ghci/should_run/T22958b.hs @@ -0,0 +1,25 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE DerivingStrategies #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnliftedDatatypes #-} +import GHC.Exts + +type D1 :: TYPE (BoxedRep Unlifted) +data D1 = MkD1 !Int + +showD1 :: D1 -> String +showD1 (MkD1 i) = "MkD1 " ++ show i + +type D2 :: TYPE (BoxedRep Lifted) +data D2 = MkD2 !Int deriving stock Show + +risky :: forall {r} (a :: TYPE (BoxedRep Unlifted)) (b :: TYPE r). a -> b +risky = unsafeCoerce# +{-# NOINLINE risky #-} + +main :: IO () +main = do + putStrLn (showD1 (unsafeCoerce# (MkD1 11))) -- foo11 + print (unsafeCoerce# (MkD1 12) :: D2) -- foo12 + putStrLn (showD1 (risky (MkD1 11))) -- bar11 + print (risky (MkD1 12) :: D2) -- bar12 |