[Git][ghc/ghc][wip/backports-9.14] 2 commits: Fix a long-standing assertion error in normSplitTyConApp_maybe
Ben Gamari pushed to branch wip/backports-9.14 at Glasgow Haskell Compiler / GHC Commits: e09e1443 by Simon Peyton Jones at 2025-08-15T12:25:41-04:00 Fix a long-standing assertion error in normSplitTyConApp_maybe (cherry picked from commit 60db2c66b870bac28615d272936bef6905befdbb) - - - - - 7b814248 by Simon Peyton Jones at 2025-08-15T12:25:50-04:00 Add comment to coercion optimiser (cherry picked from commit b2b95dce34ce7f6a8f0acdd637cbe2cafc56c922) - - - - - 2 changed files: - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/Utils.hs Changes: ===================================== compiler/GHC/Core/Coercion/Opt.hs ===================================== @@ -208,10 +208,12 @@ optCoercion' env co in warnPprTrace (not (isReflCo out_co) && isReflexiveCo out_co) "optCoercion: reflexive but not refl" details $ --- assertPpr (substTyUnchecked env in_ty1 `eqType` out_ty1 && --- substTyUnchecked env in_ty2 `eqType` out_ty2 && --- in_role == out_role) --- (hang (text "optCoercion changed types!") 2 details) $ + -- The coercion optimiser should usually optimise + -- co:ty~ty --> Refl ty + -- But given a silly `newtype N = MkN N`, the axiom has type (N ~ N), + -- and so that can trigger this warning (e.g. test str002). + -- Maybe we should optimise that coercion to (Refl N), but it + -- just doesn't seem worth the bother out_co | otherwise ===================================== compiler/GHC/Core/Utils.hs ===================================== @@ -2730,8 +2730,10 @@ normSplitTyConApp_maybe fam_envs ty | let Reduction co ty1 = topNormaliseType_maybe fam_envs ty `orElse` (mkReflRedn Representational ty) , Just (tc, tc_args) <- splitTyConApp_maybe ty1 - = assertPpr (not (isNewTyCon tc)) (ppr ty $$ ppr ty1) $ -- Check post-condition - Just (tc, tc_args, co) + , not (isNewTyCon tc) -- How can tc be a newtype, after `topNormaliseType`? + -- Answer: if it is a recursive newtype, `topNormaliseType` + -- may be a no-op. Example: tc226 + = Just (tc, tc_args, co) normSplitTyConApp_maybe _ _ = Nothing {- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/779a7bc6c1efa07e0cdf8eb125936b9... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/779a7bc6c1efa07e0cdf8eb125936b9... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Ben Gamari (@bgamari)