summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Peyton Jones <simon.peytonjones@gmail.com>2022-05-06 23:24:07 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2022-05-10 16:02:16 +0100
commit322537e3c3469090de16aeffe3fdf6fb98b68c34 (patch)
treefcbaaabce49677b0a7aac5f8c621c2003ac352dd
parenta4fbb589fd176e6c2f6648dea6c93e25668f1db8 (diff)
downloadhaskell-wip/T21516.tar.gz
Use the wrapper for an unlifted bindingwip/T21516
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, [''])