[Git][ghc/ghc][wip/t22519] Re-add depth bound for newtype unwrapping

Simon Peyton Jones (@simonpj) gitlab at gitlab.haskell.org
Tue Jan 24 14:38:06 UTC 2023



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


Commits:
dc38f757 by Simon Peyton Jones at 2023-01-24T14:38:35+00:00
Re-add depth bound for newtype unwrapping

- - - - -


1 changed file:

- compiler/GHC/Tc/Solver/Canonical.hs


Changes:

=====================================
compiler/GHC/Tc/Solver/Canonical.hs
=====================================
@@ -1507,9 +1507,11 @@ can_eq_newtype_nc ev swapped ty1 ((gres, co1), ty1') ty2 ps_ty2
   = do { traceTcS "can_eq_newtype_nc" $
          vcat [ ppr ev, ppr swapped, ppr co1, ppr gres, ppr ty1', ppr ty2 ]
 
-         -- check for blowing our stack:
+         -- Check for blowing our stack, and increase the depth
          -- See Note [Newtypes can blow the stack]
-       ; checkReductionDepth (ctEvLoc ev) ty1
+       ; let loc = ctEvLoc ev
+             ev' = ev `setCtEvLoc` bumpCtLocDepth loc
+       ; checkReductionDepth loc ty1
 
          -- Next, we record uses of newtype constructors, since coercing
          -- through newtypes is tantamount to using their constructors.
@@ -1517,7 +1519,7 @@ can_eq_newtype_nc ev swapped ty1 ((gres, co1), ty1') ty2 ps_ty2
 
        ; let redn1 = mkReduction co1 ty1'
 
-       ; new_ev <- rewriteEqEvidence emptyRewriterSet ev swapped
+       ; new_ev <- rewriteEqEvidence emptyRewriterSet ev' swapped
                      redn1
                      (mkReflRedn Representational ps_ty2)
        ; can_eq_nc False new_ev ReprEq ty1' ty1' ty2 ps_ty2 }



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dc38f757df3591736231ae7d9c532d2333285b10

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dc38f757df3591736231ae7d9c532d2333285b10
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/20230124/61f345c0/attachment-0001.html>


More information about the ghc-commits mailing list