Commit b13c6fe9 authored by eir@cis.upenn.edu's avatar eir@cis.upenn.edu Committed by Ben Gamari
Browse files

Fix #10495.

This change means that the intricate reasoning in TcErrors
around getting messages just right for nominal equalities
is skipped for representational equalities.
parent c0324c09
......@@ -815,6 +815,7 @@ mkTyVarEqErr dflags ctxt extra ct oriented tv1 ty2
-- be oriented the other way round;
-- see TcCanonical.canEqTyVarTyVar
|| isSigTyVar tv1 && not (isTyVarTy ty2)
|| ctEqRel ct == ReprEq -- the cases below don't really apply to ReprEq
= mkErrorMsg ctxt ct (vcat [ misMatchOrCND ctxt ct oriented ty1 ty2
, extraTyVarInfo ctxt tv1 ty2
, extra ])
......@@ -938,13 +939,19 @@ misMatchOrCND ctxt ct oriented ty1 ty2
isGivenCt ct
-- If the equality is unconditionally insoluble
-- or there is no context, don't report the context
= misMatchMsg oriented (ctEqRel ct) ty1 ty2
= misMatchMsg oriented eq_rel ty1 ty2
| otherwise
= couldNotDeduce givens ([mkTcEqPred ty1 ty2], orig)
= couldNotDeduce givens ([eq_pred], orig)
where
eq_rel = ctEqRel ct
givens = [ given | given@(_, _, no_eqs, _) <- getUserGivens ctxt, not no_eqs]
-- Keep only UserGivens that have some equalities
orig = TypeEqOrigin { uo_actual = ty1, uo_expected = ty2 }
(eq_pred, orig) = case eq_rel of
NomEq -> ( mkTcEqPred ty1 ty2
, TypeEqOrigin { uo_actual = ty1, uo_expected = ty2 })
ReprEq -> ( mkCoerciblePred ty1 ty2
, CoercibleOrigin ty1 ty2 )
couldNotDeduce :: [UserGiven] -> (ThetaType, CtOrigin) -> SDoc
couldNotDeduce givens (wanteds, orig)
......
T10285.hs:8:17:
Could not deduce (a ~ b)
Could not deduce (Coercible a b)
arising from trying to show that the representations of
‘a’ and
‘b’ are the same
from the context (Coercible (N a) (N b))
bound by a pattern with constructor
Coercion :: forall (k :: BOX) (a :: k) (b :: k).
......
module T10495 where
import Data.Coerce
foo = coerce
......@@ -363,3 +363,4 @@ test('T9858b', normal, compile_fail, [''])
test('T9858e', normal, compile_fail, [''])
test('T10534', extra_clean(['T10534a.hi', 'T10534a.o']),
multimod_compile_fail, ['T10534', '-v0'])
test('T10495', normal, compile_fail, [''])
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