Commit 8e8b9ed9 authored by eir@cis.upenn.edu's avatar eir@cis.upenn.edu

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.
parent e27b267f
......@@ -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
......
......@@ -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
......
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’:
......
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’
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment