[Git][ghc/ghc][wip/T24868] Wibbles

Simon Peyton Jones (@simonpj) gitlab at gitlab.haskell.org
Wed Jun 12 07:45:58 UTC 2024



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


Commits:
9d260d49 by Simon Peyton Jones at 2024-06-12T08:45:44+01:00
Wibbles

- - - - -


3 changed files:

- compiler/GHC/Core/TyCo/Tidy.hs
- compiler/GHC/Tc/Zonk/TcType.hs
- testsuite/tests/typecheck/should_fail/GivenForallLoop.stderr


Changes:

=====================================
compiler/GHC/Core/TyCo/Tidy.hs
=====================================
@@ -288,7 +288,7 @@ trimTidyEnv (occ_env, var_env) tcvs
 -- | Grabs the free type variables, tidies them
 -- and then uses 'tidyType' to work over the type itself
 tidyOpenTypesX :: TidyEnv -> [Type] -> (TidyEnv, [Type])
--- See Note [Tidying open  types]
+-- See Note [Tidying open types]
 tidyOpenTypesX env tys
   = (env1, tidyTypes inner_env tys)
   where
@@ -299,7 +299,7 @@ tidyOpenTypesX env tys
 
 ---------------
 tidyOpenTypeX :: TidyEnv -> Type -> (TidyEnv, Type)
--- See Note [Tidying open  types]
+-- See Note [Tidying open types]
 tidyOpenTypeX env ty
   = (env1, tidyType inner_env ty)
   where


=====================================
compiler/GHC/Tc/Zonk/TcType.hs
=====================================
@@ -654,13 +654,17 @@ tidyCtEvidence :: TidyEnv -> CtEvidence -> CtEvidence
      -- NB: we do not tidy the ctev_evar field because we don't
      --     show it in error messages
 tidyCtEvidence env ctev
-  = ctev { ctev_pred = tidyType env $ ctev_pred ctev }
-  -- No need for tidyOpenType because all the free tyvars are already tidied
+  = ctev { ctev_pred = tidyOpenType env $ ctev_pred ctev }
+  -- tidyOpenType: for (beta ~ (forall a. a->a), don't gratuitously
+  -- rename the 'forall a' just because of an 'a' in scope somewhere
+  -- else entirely.
 
 tidyHole :: TidyEnv -> Hole -> Hole
 tidyHole env h@(Hole { hole_ty = ty })
-  = h { hole_ty = tidyType env ty }
-  -- No need for tidyOpenType because all the free tyvars are already tidied
+  = h { hole_ty = tidyOpenType env ty }
+  -- tidyOpenType: for, say, (b -> (forall a. a->a)), don't gratuitously
+  -- rename the 'forall a' just because of an 'a' in scope somewhere
+  -- else entirely.
 
 tidyDelayedError :: TidyEnv -> DelayedError -> DelayedError
 tidyDelayedError env (DE_Hole hole)       = DE_Hole        $ tidyHole env hole


=====================================
testsuite/tests/typecheck/should_fail/GivenForallLoop.stderr
=====================================
@@ -1,16 +1,16 @@
 GivenForallLoop.hs:8:11: error: [GHC-25897]
     • Could not deduce ‘a ~ b’
-      from the context: a ~ (forall b. F a b)
+      from the context: a ~ (forall b1. F a b1)
         bound by the type signature for:
-                   loopy :: forall a b. (a ~ (forall b. F a b)) => a -> b
+                   loopy :: forall a b. (a ~ (forall b1. F a b1)) => a -> b
         at GivenForallLoop.hs:7:1-42
       ‘a’ is a rigid type variable bound by
         the type signature for:
-          loopy :: forall a b. (a ~ (forall b. F a b)) => a -> b
+          loopy :: forall a b. (a ~ (forall b1. F a b1)) => a -> b
         at GivenForallLoop.hs:7:1-42
       ‘b’ is a rigid type variable bound by
         the type signature for:
-          loopy :: forall a b. (a ~ (forall b. F a b)) => a -> b
+          loopy :: forall a b. (a ~ (forall b1. F a b1)) => a -> b
         at GivenForallLoop.hs:7:1-42
     • In the expression: x
       In an equation for ‘loopy’: loopy x = x



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

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9d260d499affe2920658f7a3b111e18fe34ab690
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/20240612/c09ff3ee/attachment-0001.html>


More information about the ghc-commits mailing list