[Git][ghc/ghc][master] Fix #22742
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Mon Jan 23 09:54:00 UTC 2023
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
82884ce0 by Simon Peyton Jones at 2023-01-23T04:53:32-05:00
Fix #22742
runtimeRepLevity_maybe was panicing unnecessarily; and
the error printing code made use of the case when it should
return Nothing rather than panicing.
For some bizarre reason perf/compiler/T21839r shows a 10% bump in runtime
peak-megagbytes-used, on a single architecture (alpine). See !9753 for
commentary, but I'm going to accept it.
Metric Increase:
T21839r
- - - - -
4 changed files:
- compiler/GHC/Core/Type.hs
- + testsuite/tests/polykinds/T22742.hs
- + testsuite/tests/polykinds/T22742.stderr
- testsuite/tests/polykinds/all.T
Changes:
=====================================
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 at .
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
=====================================
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 = ()
=====================================
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) () -> ()
=====================================
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, [''])
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/82884ce063180a39afed163590738f7095394583
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/82884ce063180a39afed163590738f7095394583
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230123/38979589/attachment-0001.html>
More information about the ghc-commits
mailing list