summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Peyton Jones <simon.peytonjones@gmail.com>2022-05-06 23:24:07 +0100
committerZubin Duggal <zubin.duggal@gmail.com>2022-05-25 16:29:15 +0530
commit63df2629544e04fc6acd38550eae68c08a7bda90 (patch)
tree832998769b696a2171789f67e26049aa2ed5d069
parent0d2f6bd5254c31b3b8891ea541aeecc3bb922a7d (diff)
downloadhaskell-63df2629544e04fc6acd38550eae68c08a7bda90.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. (cherry picked from commit 21feece2f36e8c084ccd87579e48f2b03d5346d0)
-rw-r--r--compiler/GHC/HsToCore/Expr.hs4
-rw-r--r--testsuite/tests/typecheck/should_compile/T21516.hs8
-rw-r--r--testsuite/tests/typecheck/should_compile/all.T1
3 files changed, 11 insertions, 2 deletions
diff --git a/compiler/GHC/HsToCore/Expr.hs b/compiler/GHC/HsToCore/Expr.hs
index f90b44d9c9..9ce903286d 100644
--- a/compiler/GHC/HsToCore/Expr.hs
+++ b/compiler/GHC/HsToCore/Expr.hs
@@ -209,8 +209,8 @@ dsUnliftedBind (FunBind { fun_id = L l fun
= 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
+ ; 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 98d5912a9a..147c84d7d9 100644
--- a/testsuite/tests/typecheck/should_compile/all.T
+++ b/testsuite/tests/typecheck/should_compile/all.T
@@ -786,3 +786,4 @@ test('T18467', normal, compile, [''])
test('T19315', normal, compile, [''])
test('T19535', normal, compile, [''])
+test('T21516', normal, compile, [''])