summaryrefslogtreecommitdiff
path: root/testsuite/tests/polykinds/T14561.hs
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2017-12-13 10:46:26 +0000
committerSimon Peyton Jones <simonpj@microsoft.com>2017-12-13 10:52:10 +0000
commite40db7b1676627f5291b463405338e7b69fa3f69 (patch)
tree8426bae8d6097dcd89fc55282c0167bae33b12b9 /testsuite/tests/polykinds/T14561.hs
parenta106a200892e2ac7953f0929c303d392c8808f89 (diff)
downloadhaskell-e40db7b1676627f5291b463405338e7b69fa3f69.tar.gz
Detect levity-polymorphic uses of unsafeCoerce#
This bug was shown up by Trac #14561. The deguarer carefully detects unsaturated and levity-polymorphic uses of primops, but not of things like unsafeCoerce#. The fix is simple: see Note [Levity-polymorphic Ids] in Id.
Diffstat (limited to 'testsuite/tests/polykinds/T14561.hs')
-rw-r--r--testsuite/tests/polykinds/T14561.hs18
1 files changed, 18 insertions, 0 deletions
diff --git a/testsuite/tests/polykinds/T14561.hs b/testsuite/tests/polykinds/T14561.hs
new file mode 100644
index 0000000000..f528e7c813
--- /dev/null
+++ b/testsuite/tests/polykinds/T14561.hs
@@ -0,0 +1,18 @@
+{-# LANGUAGE TypeInType #-}
+{-# LANGUAGE RankNTypes #-}
+{-# LANGUAGE PolyKinds #-}
+{-# LANGUAGE MagicHash #-}
+
+module T14561 where
+
+import GHC.Types
+import GHC.Prim
+
+badId :: forall (a :: TYPE r). a -> a
+badId = unsafeCoerce#
+-- Un-saturated application of a levity-polymorphic
+-- function that must be eta-expanded
+
+goodId :: forall (a :: Type). a -> a
+goodId = unsafeCoerce#
+-- But this one is OK