summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Peyton Jones <simon.peytonjones@gmail.com>2022-05-06 23:24:07 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-05-10 20:48:39 -0400
commit21feece2f36e8c084ccd87579e48f2b03d5346d0 (patch)
tree3c1baad67819fd9af71f862f13bee63942a1c7a9
parent699f593532a3cd5ca1c2fab6e6e4ce9d53be2c1f (diff)
downloadhaskell-21feece2f36e8c084ccd87579e48f2b03d5346d0.tar.gz
Use the wrapper for an unlifted binding
We assumed the wrapper for an unlifted binding is the identity, but as #21516 showed, that is no always true. Solution is simple: use it.
-rw-r--r--compiler/GHC/HsToCore/Expr.hs6
-rw-r--r--testsuite/tests/typecheck/should_compile/T21516.hs8
-rw-r--r--testsuite/tests/typecheck/should_compile/all.T1
3 files changed, 12 insertions, 3 deletions
diff --git a/compiler/GHC/HsToCore/Expr.hs b/compiler/GHC/HsToCore/Expr.hs
index 565338d5a7..88dc4f7d45 100644
--- a/compiler/GHC/HsToCore/Expr.hs
+++ b/compiler/GHC/HsToCore/Expr.hs
@@ -196,9 +196,9 @@ dsUnliftedBind (FunBind { fun_id = L l fun
-- Can't be a bang pattern (that looks like a PatBind)
-- so must be simply unboxed
= do { (args, rhs) <- matchWrapper (mkPrefixFunRhs (L l $ idName fun)) Nothing matches
- ; massert (null args) -- Functions aren't lifted
- ; massert (isIdHsWrapper co_fn)
- ; let rhs' = mkOptTickBox tick rhs
+ ; massert (null args) -- Functions aren't unlifted
+ ; core_wrap <- dsHsWrapper co_fn -- Can be non-identity (#21516)
+ ; let rhs' = core_wrap (mkOptTickBox tick rhs)
; return (bindNonRec fun rhs' body) }
dsUnliftedBind (PatBind {pat_lhs = pat, pat_rhs = grhss
diff --git a/testsuite/tests/typecheck/should_compile/T21516.hs b/testsuite/tests/typecheck/should_compile/T21516.hs
new file mode 100644
index 0000000000..d7d180cc5f
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/T21516.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE DataKinds, KindSignatures, ExplicitForAll #-}
+module T where
+
+import GHC.Exts
+
+a = let x :: forall (a :: TYPE IntRep). a
+ x = error ""
+ in ()
diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T
index f110e273a8..1764ccb34b 100644
--- a/testsuite/tests/typecheck/should_compile/all.T
+++ b/testsuite/tests/typecheck/should_compile/all.T
@@ -824,3 +824,4 @@ test('T21023', normal, compile, ['-ddump-types'])
test('T21205', normal, compile, ['-O0'])
test('T21323', normal, compile, [''])
test('T21315', normal, compile, ['-Wredundant-constraints'])
+test('T21516', normal, compile, [''])