[commit: ghc] master: Fix #12919 by making the flattener homegeneous. (e3dbb44)
git at git.haskell.org
git at git.haskell.org
Mon Mar 26 21:25:34 UTC 2018
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/e3dbb44f53b2f9403d20d84e27f187062755a089/ghc
>---------------------------------------------------------------
commit e3dbb44f53b2f9403d20d84e27f187062755a089
Author: Richard Eisenberg <rae at cs.brynmawr.edu>
Date: Thu Aug 3 15:18:39 2017 -0400
Fix #12919 by making the flattener homegeneous.
This changes a key invariant of the flattener. Previously,
flattening a type meant flattening its kind as well. But now,
flattening is always homogeneous -- that is, the kind of the
flattened type is the same as the kind of the input type.
This is achieved by various wizardry in the TcFlatten.flatten_many
function, as described in Note [flatten_many].
There are several knock-on effects, including some refactoring
in the canonicalizer to take proper advantage of the flattener's
changed behavior. In particular, the tyvar case of can_eq_nc' no
longer needs to take casts into account.
Another effect is that flattening a tyconapp might change it
into a casted tyconapp. This might happen if the result kind
of the tycon contains a variable, and that variable changes
during flattening. Because the flattener is homogeneous, it tacks
on a cast to keep the tyconapp kind the same. However, this
is problematic when flattening CFunEqCans, which need to have
an uncasted tyconapp on the LHS and must remain homogeneous.
The solution is a more involved canCFunEqCan, described in
Note [canCFunEqCan].
This patch fixes #13643 (as tested in typecheck/should_compile/T13643)
and the panic in typecheck/should_compile/T13822 (as reported in #14024).
Actually, there were two bugs in T13822: the first was just some
incorrect logic in tryFill (part of the unflattener) -- also fixed
in this patch -- and the other was the main bug fixed in this ticket.
The changes in this patch exposed a long-standing flaw in OptCoercion,
in that breaking apart an AppCo sometimes has unexpected effects on
kinds. See new Note [EtaAppCo] in OptCoercion, which explains the
problem and fix.
Also here is a reversion of the major change in
09bf135ace55ce2572bf4168124d631e386c64bb, affecting ctEvCoercion.
It turns out that making the flattener homogeneous changes the
invariants on the algorithm, making the change in that patch
no longer necessary.
This patch also fixes:
#14038 (dependent/should_compile/T14038)
#13910 (dependent/should_compile/T13910)
#13938 (dependent/should_compile/T13938)
#14441 (typecheck/should_compile/T14441)
#14556 (dependent/should_compile/T14556)
#14720 (dependent/should_compile/T14720)
#14749 (typecheck/should_compile/T14749)
Sadly, this patch negatively affects performance of type-family-
heavy code. The following patch fixes these performance degradations.
However, the performance fixes are somewhat invasive and so I've
kept them as a separate patch, labeling this one as [skip ci] so
that validation doesn't fail on the performance cases.
>---------------------------------------------------------------
e3dbb44f53b2f9403d20d84e27f187062755a089
compiler/typecheck/TcCanonical.hs | 334 ++++++---
compiler/typecheck/TcFlatten.hs | 782 ++++++++++++++-------
compiler/typecheck/TcInteract.hs | 51 +-
compiler/typecheck/TcMType.hs | 11 +-
compiler/typecheck/TcRnTypes.hs | 15 +-
compiler/typecheck/TcSMonad.hs | 100 ++-
compiler/typecheck/TcType.hs | 2 +-
compiler/types/Coercion.hs | 235 ++++---
compiler/types/Coercion.hs-boot | 1 +
compiler/types/OptCoercion.hs | 110 ++-
compiler/types/TyCoRep.hs | 83 ++-
compiler/types/Type.hs | 84 +--
testsuite/tests/dependent/should_compile/T14556.hs | 38 +
testsuite/tests/dependent/should_compile/T14720.hs | 44 ++
testsuite/tests/dependent/should_compile/all.T | 8 +-
.../tests/dependent/should_fail/RAE_T32a.stderr | 25 +-
testsuite/tests/dependent/should_fail/all.T | 2 +-
.../tests/typecheck/should_compile/SplitWD.hs | 55 ++
testsuite/tests/typecheck/should_compile/T13643.hs | 22 +
testsuite/tests/typecheck/should_compile/T14441.hs | 15 +
testsuite/tests/typecheck/should_compile/T14749.hs | 27 +
testsuite/tests/typecheck/should_compile/all.T | 8 +-
.../tests/typecheck/should_fail/T12373.stderr | 8 +-
.../tests/typecheck/should_run/Typeable1.stderr | 3 +-
24 files changed, 1408 insertions(+), 655 deletions(-)
Diff suppressed because of size. To see it, use:
git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc e3dbb44f53b2f9403d20d84e27f187062755a089
More information about the ghc-commits
mailing list