RE: [commit: ghc] wip/T14068: Avoid name capture in setJoinResTy (6a50466)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: [commit: ghc] wip/T14068: Avoid name capture in setJoinResTy (6a50466)

GHC - devs mailing list
Joachim

Aha!  I think my comment on Phab is redundant.  You are simply avoiding name capture, which is obviously right; you are not restricting the applicability of the transformation.

Needless to say, a Note would help in due course.

S

|  -----Original Message-----
|  From: ghc-commits [mailto:[hidden email]] On Behalf
|  Of [hidden email]
|  Sent: 02 August 2017 04:07
|  To: [hidden email]
|  Subject: [commit: ghc] wip/T14068: Avoid name capture in setJoinResTy
|  (6a50466)
|  
|  Repository : ssh://[hidden email]/ghc
|  
|  On branch  : wip/T14068
|  Link       :
|  https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fghc.ha
|  skell.org%2Ftrac%2Fghc%2Fchangeset%2F6a5046684f93f1870663119b447fff6ba
|  eb7a7c4%2Fghc&data=04%7C01%7Csimonpj%40microsoft.com%7Cc45ce3f4deea476
|  9222b08d4d953af74%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C6363724
|  00832017356%7CUnknown%7CVW5rbm93bnx7IlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMi
|  IsIkFOIjoiT3RoZXIifQ%3D%3D%7C-
|  1&sdata=29Iajm6oTE3Zm%2Bdl5ocMav7MPw%2FniO9%2BVeuQm38qWXQ%3D&reserved=
|  0
|  
|  >---------------------------------------------------------------
|  
|  commit 6a5046684f93f1870663119b447fff6baeb7a7c4
|  Author: Joachim Breitner <[hidden email]>
|  Date:   Tue Aug 1 22:48:26 2017 -0400
|  
|      Avoid name capture in setJoinResTy
|  
|  
|  >---------------------------------------------------------------
|  
|  6a5046684f93f1870663119b447fff6baeb7a7c4
|   compiler/types/Type.hs | 22 ++++++++++++++++------
|   1 file changed, 16 insertions(+), 6 deletions(-)
|  
|  diff --git a/compiler/types/Type.hs b/compiler/types/Type.hs index
|  50a35b0..c69d4ff 100644
|  --- a/compiler/types/Type.hs
|  +++ b/compiler/types/Type.hs
|  @@ -2445,11 +2445,21 @@ setJoinResTy :: Int  -- Number of binders to
|  skip
|                -> Type -- New type
|   -- INVARIANT: If any of the first n binders are foralls, those tyvars
|  cannot
|   -- appear in the original result type. See isValidJoinPointType.
|  +--
|  +-- When we set the return type under a forall, avoid capture!
|   setJoinResTy orig_ar new_res_ty orig_ty
|  -  = go orig_ar orig_ty
|  +  = go init_subst orig_ar orig_ty
|     where
|  -    go 0 _  = new_res_ty
|  -    go n ty | Just (arg_bndr, res_ty) <- splitPiTy_maybe ty
|  -            = mkPiTy arg_bndr (go (n-1) res_ty)
|  -            | otherwise
|  -            = pprPanic "setJoinResTy" (ppr orig_ar <+> ppr orig_ty)
|  +    init_subst :: TCvSubst
|  +    init_subst = mkEmptyTCvSubst (mkInScopeSet (tyCoVarsOfType
|  + new_res_ty))
|  +
|  +    go _     0 _  = new_res_ty
|  +    go subst n ty
|  +        | Just (t, ty') <- splitForAllTy_maybe ty
|  +        , let (subst', t') = substTyVarBndr subst t
|  +        = mkForAllTy t' Inferred (go subst' (n-1) ty')
|  +        | Just (arg_ty, ty') <- splitFunTy_maybe ty
|  +        , let arg_ty' = substTy subst arg_ty
|  +        = mkFunTy arg_ty' (go subst (n-1) ty')
|  +        | otherwise
|  +        = pprPanic "setJoinResTy" (ppr orig_ar <+> ppr orig_ty)
|  
|  _______________________________________________
|  ghc-commits mailing list
|  [hidden email]
|  https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmail.h
|  askell.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fghc-
|  commits&data=04%7C01%7Csimonpj%40microsoft.com%7Cc45ce3f4deea4769222b0
|  8d4d953af74%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C6363724008320
|  17356%7CUnknown%7CVW5rbm93bnx7IlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFO
|  IjoiT3RoZXIifQ%3D%3D%7C-
|  1&sdata=7%2FAY0EcihvMkjGOHdYdpOog2Roahk0XD%2BunNg54pKFc%3D&reserved=0
_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Loading...