[commit: ghc] wip/rae: Run simplifier only when the env is clean. (0d965fc)

git at git.haskell.org git at git.haskell.org
Sun Sep 20 20:28:14 UTC 2015


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

On branch  : wip/rae
Link       : http://ghc.haskell.org/trac/ghc/changeset/0d965fcb542a8bfff94b41666c765cca8bf37d06/ghc

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

commit 0d965fcb542a8bfff94b41666c765cca8bf37d06
Author: Richard Eisenberg <eir at cis.upenn.edu>
Date:   Sun Sep 20 16:15:13 2015 -0400

    Run simplifier only when the env is clean.
    
    This fixes #10896. In the indexed-types/should_fail/BadSock test,
    there is a bad type definition. This gets type-checked, an error
    gets reported, but then **GHC keeps going**. Later, when
    running the simplifier to do an ambiguity check, the bad type
    environment causes GHC to fall over. My solution: only run the
    simplifier in a clean, error-free type environment.


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

0d965fcb542a8bfff94b41666c765cca8bf37d06
 compiler/typecheck/TcFlatten.hs  | 4 +++-
 compiler/typecheck/TcValidity.hs | 6 +++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/compiler/typecheck/TcFlatten.hs b/compiler/typecheck/TcFlatten.hs
index 052c158..efc9e32 100644
--- a/compiler/typecheck/TcFlatten.hs
+++ b/compiler/typecheck/TcFlatten.hs
@@ -1038,7 +1038,9 @@ flatten_fam_app, flatten_exact_fam_app, flatten_exact_fam_app_fully
   --   flatten_exact_fam_app_fully lifts out the application to top level
   -- Postcondition: Coercion :: Xi ~ F tys
 flatten_fam_app tc tys  -- Can be over-saturated
-    = ASSERT( tyConArity tc <= length tys )  -- Type functions are saturated
+    = ASSERT2( tyConArity tc <= length tys
+             , ppr tc $$ ppr (tyConArity tc) $$ ppr tys)
+                 -- Type functions are saturated
                  -- The type function might be *over* saturated
                  -- in which case the remaining arguments should
                  -- be dealt with by AppTys
diff --git a/compiler/typecheck/TcValidity.hs b/compiler/typecheck/TcValidity.hs
index 4f20a3d..9063dd6 100644
--- a/compiler/typecheck/TcValidity.hs
+++ b/compiler/typecheck/TcValidity.hs
@@ -215,7 +215,11 @@ checkAmbiguity ctxt ty
        ; (_wrap, wanted) <- addErrCtxtM (mk_msg ty') $
                             captureConstraints $
                             tcSubType_NC ctxt ty' ty'
-       ; simplifyAmbiguityCheck ty wanted
+       ; whenNoErrs $  -- only run the simplifier if we have a clean
+                       -- environment. Otherwise we might trip.
+                       -- example: indexed-types/should_fail/BadSock
+                       -- fails in DEBUG mode without this
+         simplifyAmbiguityCheck ty wanted
 
        ; traceTc "Done ambiguity check for" (ppr ty) }
  where



More information about the ghc-commits mailing list