Flattener preserves synonyms, rewriteEvidence can drop buggy "optimisation"
authorSimon Peyton Jones <simonpj@microsoft.com>
Fri, 21 Mar 2014 15:37:27 +0000 (15:37 +0000)
committerSimon Peyton Jones <simonpj@microsoft.com>
Mon, 24 Mar 2014 08:28:02 +0000 (08:28 +0000)
commit6ae678e31a5fdd3b0bd1f8613fe164012bb630f4
tree030d876631634663d3bad8f14ae5ca8d0a9ae41a
parent9f9b10f65d09823c21bc19a79e14cf27cfe56ea5
Flattener preserves synonyms, rewriteEvidence can drop buggy "optimisation"

There was a special case in rewriteEvidence, looking like:
  = return (Just (if ctEvPred old_ev `tcEqType` new_pred
                  then old_ev
                  else old_ev { ctev_pred = new_pred }))

But this was wrong: old_pred and new_pred might differ in the kind
of a TyVar occurrence, in which case tcEqType would not notice,
but we really, really want new_pred.  This caused Trac #8913.

I solved this by dropping the whole test, and instead making
the flattener preserve type synonyms. This was easy because
TcEvidence has TcTyConAppCo which (unlike) Coercion, handles
synonyms.
compiler/typecheck/TcCanonical.lhs
compiler/typecheck/TcSMonad.lhs
testsuite/tests/indexed-types/should_compile/T8913.hs [new file with mode: 0644]
testsuite/tests/indexed-types/should_compile/all.T
testsuite/tests/simplCore/should_compile/simpl017.stderr