[commit: ghc] wip/rae: Run simplifier only when the env is clean. (8e8b9ed)
git at git.haskell.org
git at git.haskell.org
Mon Sep 21 14:52:26 UTC 2015
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/rae
Link : http://ghc.haskell.org/trac/ghc/changeset/8e8b9ed9849ba21e454e6204b368f8e993feaf7b/ghc
>---------------------------------------------------------------
commit 8e8b9ed9849ba21e454e6204b368f8e993feaf7b
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.
A downside of this is that fewer error messages are reported.
This makes me a bit sad, but I'm not sure how to avoid the problem.
Suggestions welcome.
>---------------------------------------------------------------
8e8b9ed9849ba21e454e6204b368f8e993feaf7b
compiler/typecheck/TcFlatten.hs | 4 +++-
compiler/typecheck/TcValidity.hs | 6 +++++-
testsuite/tests/typecheck/should_fail/T5300.stderr | 21 +++------------------
testsuite/tests/typecheck/should_fail/T8030.stderr | 15 +--------------
4 files changed, 12 insertions(+), 34 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 c21e683..ae416e7 100644
--- a/compiler/typecheck/TcValidity.hs
+++ b/compiler/typecheck/TcValidity.hs
@@ -216,7 +216,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
diff --git a/testsuite/tests/typecheck/should_fail/T5300.stderr b/testsuite/tests/typecheck/should_fail/T5300.stderr
index 851d017..7e06b62 100644
--- a/testsuite/tests/typecheck/should_fail/T5300.stderr
+++ b/testsuite/tests/typecheck/should_fail/T5300.stderr
@@ -1,25 +1,10 @@
-T5300.hs:11:7:
- Could not deduce (C1 a b c0)
- from the context: (Monad m, C1 a b c)
- bound by the type signature for:
- f1 :: (Monad m, C1 a b c) => a -> StateT (T b) m a
- at T5300.hs:11:7-50
- The type variable ‘c0’ is ambiguous
- In the ambiguity check for the type signature for ‘f1’:
- f1 :: forall a b (m :: * -> *) c.
- (Monad m, C1 a b c) =>
- a -> StateT (T b) m a
- To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
- In the type signature for ‘f1’:
- f1 :: (Monad m, C1 a b c) => a -> StateT (T b) m a
-
-T5300.hs:14:7:
+T5300.hs:14:7: error:
Could not deduce (C2 a2 b2 c20)
from the context: (Monad m, C1 a1 b1 c1, C2 a2 b2 c2)
bound by the type signature for:
- f2 :: (Monad m, C1 a1 b1 c1, C2 a2 b2 c2) =>
- a1 -> StateT (T b2) m a2
+ f2 :: (Monad m, C1 a1 b1 c1, C2 a2 b2 c2) =>
+ a1 -> StateT (T b2) m a2
at T5300.hs:14:7-69
The type variable ‘c20’ is ambiguous
In the ambiguity check for the type signature for ‘f2’:
diff --git a/testsuite/tests/typecheck/should_fail/T8030.stderr b/testsuite/tests/typecheck/should_fail/T8030.stderr
index 8dd752e..831cf42 100644
--- a/testsuite/tests/typecheck/should_fail/T8030.stderr
+++ b/testsuite/tests/typecheck/should_fail/T8030.stderr
@@ -1,5 +1,5 @@
-T8030.hs:9:3:
+T8030.hs:9:3: error:
Couldn't match expected type ‘Pr a’ with actual type ‘Pr a0’
NB: ‘Pr’ is a type function, and may not be injective
The type variable ‘a0’ is ambiguous
@@ -9,16 +9,3 @@ T8030.hs:9:3:
When checking the class method:
op1 :: forall (k :: BOX) (a :: k). C a => Pr a
In the class declaration for ‘C’
-
-T8030.hs:10:3:
- Couldn't match type ‘Pr a0’ with ‘Pr a’
- NB: ‘Pr’ is a type function, and may not be injective
- The type variable ‘a0’ is ambiguous
- Expected type: Pr a -> Pr a -> Pr a
- Actual type: Pr a0 -> Pr a0 -> Pr a0
- In the ambiguity check for the type signature for ‘op2’:
- op2 :: forall (k :: BOX) (a :: k). C a => Pr a -> Pr a -> Pr a
- To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
- When checking the class method:
- op2 :: forall (k :: BOX) (a :: k). C a => Pr a -> Pr a -> Pr a
- In the class declaration for ‘C’
More information about the ghc-commits
mailing list