Commit 82884ce0 authored by Simon Peyton Jones's avatar Simon Peyton Jones Committed by Marge Bot
Browse files

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
parent 9a9bec57
Pipeline #61998 failed with stages
in 393 minutes and 53 seconds
......@@ -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
......
module T22742 where
import GHC.Exts (TYPE)
data T (a :: TYPE r) = MkT
f :: T @(f a b) () -> ()
f MkT = ()
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) () -> ()
......@@ -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, [''])
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment