Simon Peyton Jones pushed to branch wip/T27994 at Glasgow Haskell Compiler / GHC Commits: 0b7cebad by Simon Peyton Jones at 2026-10-28T14:47:54+00:00 niFixSubst: invert test and add a counter to detect loop - - - - - 1 changed file: - compiler/GHC/Core/Unify.hs Changes: ===================================== compiler/GHC/Core/Unify.hs ===================================== @@ -1132,7 +1132,7 @@ Ugh! This whole thing is pretty horrible. We work as follows: In our example, the substitution is now a fixpoint. -} -niFixSubst, niFixSubst' :: InScopeSet -> TvSubstEnv -> Subst +niFixSubst :: InScopeSet -> TvSubstEnv -> Subst -- Find the idempotent fixed point of the non-idempotent substitution -- This is surprisingly tricky: -- see Note [Finding the substitution fixpoint] @@ -1145,11 +1145,13 @@ niFixSubst in_scope tenv -- , text "Out:" <+> ppr (S.getTvSubstEnv subst) ]) subst where - subst = niFixSubst' in_scope tenv + subst = niFixSubst' 1 in_scope tenv -niFixSubst' in_scope tenv_orig +niFixSubst' :: Int -> InScopeSet -> TvSubstEnv -> Subst +niFixSubst' n in_scope tenv_orig | fixpoint_found = mkTvSubst in_scope tenv_orig - | otherwise = niFixSubst' in_scope tenv_new + | otherwise = (if n>5 then pprTrace "niFixSubst" (ppr tenv_orig) else id) $ + niFixSubst' (n+1) in_scope tenv_new where in_dom tv = tv `elemVarEnv` tenv_orig tenv_new = mapVarEnv (deepSubstTy subst) tenv_orig @@ -1158,7 +1160,7 @@ niFixSubst' in_scope tenv_orig fixpoint_found = nonDetStrictFoldUFM and_fix True tenv_orig and_fix :: Type -> Bool -> Bool and_fix _ False = False - and_fix ty _ = anyFreeVarsOfType in_dom ty + and_fix ty _ = not (anyFreeVarsOfType in_dom ty) {- range_tvs :: [TyVar] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0b7cebad3132bbb556b367910a8df4e3... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0b7cebad3132bbb556b367910a8df4e3... You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help