Simon Peyton Jones pushed to branch wip/T27994 at Glasgow Haskell Compiler / GHC

Commits:

1 changed file:

Changes:

  • compiler/GHC/Core/Unify.hs
    ... ... @@ -1132,7 +1132,7 @@ Ugh! This whole thing is pretty horrible. We work as follows:
    1132 1132
     In our example, the substitution is now a fixpoint.
    
    1133 1133
     -}
    
    1134 1134
     
    
    1135
    -niFixSubst, niFixSubst' :: InScopeSet -> TvSubstEnv -> Subst
    
    1135
    +niFixSubst :: InScopeSet -> TvSubstEnv -> Subst
    
    1136 1136
     -- Find the idempotent fixed point of the non-idempotent substitution
    
    1137 1137
     -- This is surprisingly tricky:
    
    1138 1138
     --   see Note [Finding the substitution fixpoint]
    
    ... ... @@ -1145,11 +1145,13 @@ niFixSubst in_scope tenv
    1145 1145
          --                             , text "Out:" <+> ppr (S.getTvSubstEnv subst) ])
    
    1146 1146
          subst
    
    1147 1147
       where
    
    1148
    -     subst = niFixSubst' in_scope tenv
    
    1148
    +     subst = niFixSubst' 1 in_scope tenv
    
    1149 1149
     
    
    1150
    -niFixSubst' in_scope tenv_orig
    
    1150
    +niFixSubst' :: Int -> InScopeSet -> TvSubstEnv -> Subst
    
    1151
    +niFixSubst' n in_scope tenv_orig
    
    1151 1152
       | fixpoint_found = mkTvSubst in_scope tenv_orig
    
    1152
    -  | otherwise      = niFixSubst' in_scope tenv_new
    
    1153
    +  | otherwise      = (if n>5 then pprTrace "niFixSubst" (ppr tenv_orig) else id) $
    
    1154
    +                     niFixSubst' (n+1) in_scope tenv_new
    
    1153 1155
       where
    
    1154 1156
         in_dom tv = tv `elemVarEnv` tenv_orig
    
    1155 1157
         tenv_new  = mapVarEnv (deepSubstTy subst) tenv_orig
    
    ... ... @@ -1158,7 +1160,7 @@ niFixSubst' in_scope tenv_orig
    1158 1160
         fixpoint_found = nonDetStrictFoldUFM and_fix True tenv_orig
    
    1159 1161
         and_fix :: Type -> Bool -> Bool
    
    1160 1162
         and_fix _ False = False
    
    1161
    -    and_fix ty _    = anyFreeVarsOfType in_dom ty
    
    1163
    +    and_fix ty _    = not (anyFreeVarsOfType in_dom ty)
    
    1162 1164
     
    
    1163 1165
     {-
    
    1164 1166
         range_tvs :: [TyVar]