[commit: ghc] master: Fix the bind-recovery type (807ab22)

git at git.haskell.org git at git.haskell.org
Fri Jun 15 11:12:59 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/807ab222d08c11a4d00064c9835f9ed9f20ffc7c/ghc

>---------------------------------------------------------------

commit 807ab222d08c11a4d00064c9835f9ed9f20ffc7c
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Fri Jun 15 09:08:58 2018 +0100

    Fix the bind-recovery type
    
    This patch uses (forall (a::*). a) for the type to
    use when recovering from an error in a binding.
    
    Previously (Trac #15276) we had (forall r (a :: TYPE r). a),
    which is ill-kinded.
    
    It's quite hard to provoke an error arising from this, because
    it only happens in programs that have a type error anyway,
    but in a subequent patch I make typeKind fall over if it returns
    an ill-scoped kind, and that makes ghci/scripts/T13202 crash
    without this fix.


>---------------------------------------------------------------

807ab222d08c11a4d00064c9835f9ed9f20ffc7c
 compiler/typecheck/TcBinds.hs | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/compiler/typecheck/TcBinds.hs b/compiler/typecheck/TcBinds.hs
index 85c1b0c..fadf0e9 100644
--- a/compiler/typecheck/TcBinds.hs
+++ b/compiler/typecheck/TcBinds.hs
@@ -646,7 +646,13 @@ recoveryCode binder_names sig_fn
       = mkLocalId name forall_a_a
 
 forall_a_a :: TcType
-forall_a_a = mkSpecForAllTys [runtimeRep1TyVar, openAlphaTyVar] openAlphaTy
+-- At one point I had (forall r (a :: TYPE r). a), but of course
+-- that type is ill-formed: its mentions 'r' which escapes r's scope.
+-- Another alternative would be (forall (a :: TYPE kappa). a), where
+-- kappa is a unification variable. But I don't think we need that
+-- complication here. I'm going to just use (forall (a::*). a).
+-- See Trac #15276
+forall_a_a = mkSpecForAllTys [alphaTyVar] alphaTy
 
 {- *********************************************************************
 *                                                                      *



More information about the ghc-commits mailing list