summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/GHC/Core/Type.hs11
-rw-r--r--testsuite/tests/polykinds/T22742.hs8
-rw-r--r--testsuite/tests/polykinds/T22742.stderr6
-rw-r--r--testsuite/tests/polykinds/all.T1
4 files changed, 22 insertions, 4 deletions
diff --git a/compiler/GHC/Core/Type.hs b/compiler/GHC/Core/Type.hs
index 81b0f1e31b..9e0d95b0d9 100644
--- a/compiler/GHC/Core/Type.hs
+++ b/compiler/GHC/Core/Type.hs
@@ -686,8 +686,8 @@ kindBoxedRepLevity_maybe ty
-- * False of type variables, type family applications,
-- and of other reps such as @IntRep :: RuntimeRep@.
isLiftedRuntimeRep :: RuntimeRepType -> Bool
-isLiftedRuntimeRep rep =
- runtimeRepLevity_maybe rep == Just Lifted
+isLiftedRuntimeRep rep
+ = runtimeRepLevity_maybe rep == Just Lifted
-- | Check whether a type of kind 'RuntimeRep' is unlifted.
--
@@ -779,7 +779,8 @@ isBoxedRuntimeRep_maybe rep
| otherwise
= Nothing
--- | Check whether a type of kind 'RuntimeRep' is lifted, unlifted, or unknown.
+-- | Check whether a type (usually of kind 'RuntimeRep') is lifted, unlifted,
+-- or unknown. Returns Nothing if the type isn't of kind 'RuntimeRep'.
--
-- `runtimeRepLevity_maybe rr` returns:
--
@@ -793,7 +794,9 @@ runtimeRepLevity_maybe rep
if (rr_tc `hasKey` boxedRepDataConKey)
then case args of
[lev] -> levityType_maybe lev
- _ -> pprPanic "runtimeRepLevity_maybe" (ppr rep)
+ _ -> Nothing -- Type isn't of kind RuntimeRep
+ -- The latter case happens via the call to isLiftedRuntimeRep
+ -- in GHC.Tc.Errors.Ppr.pprMisMatchMsg (#22742)
else Just Unlifted
-- Avoid searching all the unlifted RuntimeRep type cons
-- In the RuntimeRep data type, only LiftedRep is lifted
diff --git a/testsuite/tests/polykinds/T22742.hs b/testsuite/tests/polykinds/T22742.hs
new file mode 100644
index 0000000000..d24164156b
--- /dev/null
+++ b/testsuite/tests/polykinds/T22742.hs
@@ -0,0 +1,8 @@
+module T22742 where
+
+import GHC.Exts (TYPE)
+
+data T (a :: TYPE r) = MkT
+
+f :: T @(f a b) () -> ()
+f MkT = ()
diff --git a/testsuite/tests/polykinds/T22742.stderr b/testsuite/tests/polykinds/T22742.stderr
new file mode 100644
index 0000000000..93d5f235a6
--- /dev/null
+++ b/testsuite/tests/polykinds/T22742.stderr
@@ -0,0 +1,6 @@
+
+T22742.hs:7:17: error: [GHC-83865]
+ • Couldn't match kind ‘GHC.Types.BoxedRep’ with ‘f a’
+ Expected kind ‘TYPE (f a b)’, but ‘()’ has kind ‘*’
+ • In the second argument of ‘T’, namely ‘()’
+ In the type signature: f :: T @(f a b) () -> ()
diff --git a/testsuite/tests/polykinds/all.T b/testsuite/tests/polykinds/all.T
index b23e76c025..a73508858c 100644
--- a/testsuite/tests/polykinds/all.T
+++ b/testsuite/tests/polykinds/all.T
@@ -242,3 +242,4 @@ test('T19739d', normal, compile, [''])
test('T22379a', normal, compile, [''])
test('T22379b', normal, compile, [''])
test('T22743', normal, compile_fail, [''])
+test('T22742', normal, compile_fail, [''])