From e40db7b1676627f5291b463405338e7b69fa3f69 Mon Sep 17 00:00:00 2001 From: Simon Peyton Jones Date: Wed, 13 Dec 2017 10:46:26 +0000 Subject: 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. --- testsuite/tests/polykinds/T14561.hs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 testsuite/tests/polykinds/T14561.hs (limited to 'testsuite/tests/polykinds/T14561.hs') 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 -- cgit v1.2.1