[commit: ghc] master: Re-engineer Given flatten-skolems (8dc6d64)
git at git.haskell.org
git at git.haskell.org
Fri May 26 08:55:18 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/8dc6d645fc3384b3b8ded0578939f5c855dd2ed5/ghc
>---------------------------------------------------------------
commit 8dc6d645fc3384b3b8ded0578939f5c855dd2ed5
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date: Fri May 26 09:31:38 2017 +0100
Re-engineer Given flatten-skolems
The big change here is to fix an outright bug in flattening of Givens,
albeit one that is very hard to exhibit. Suppose we have the constraint
forall a. (a ~ F b) => ..., (forall c. ....(F b)...) ...
Then
- we'll flatten the (F) b to a fsk, say (F b ~ fsk1)
- we'll rewrite the (F b) inside the inner implication to 'fsk1'
- when we leave the outer constraint we are suppose to unflatten;
but that fsk1 will still be there
- if we re-simplify the entire outer implication, we'll re-flatten
the Given (F b) to, say, (F b ~ fsk2)
Now we have two fsks standing for the same thing, and that is very
wrong.
Solution: make fsks behave more like fmvs:
- A flatten-skolem is now a MetaTyVar, whose MetaInfo is FlatSkolTv
- We "fill in" that meta-tyvar when leaving the implication
- The old FlatSkol form of TcTyVarDetails is gone completely
- We track the flatten-skolems for the current implication in
a new field of InertSet, inert_fsks.
See Note [The flattening story] in TcFlatten.
In doing this I found various other things to fix:
* I removed the zonkSimples from TcFlatten.unflattenWanteds; it wasn't
needed. But I added one in TcSimplify.floatEqualities, which does
the zonk precisely when it is needed.
* Trac #13674 showed up a case where we had
- an insoluble Given, e.g. a ~ [a]
- the same insoluble Wanted a ~ [a]
We don't use the Given to rewwrite the Wanted (obviously), but
we therefore ended up reporting
Can't deduce (a ~ [a]) from (a ~ [a])
which is silly.
Conclusion: when reporting errors, make the occurs check "win"
See Note [Occurs check wins] in TcErrors
>---------------------------------------------------------------
8dc6d645fc3384b3b8ded0578939f5c855dd2ed5
compiler/typecheck/TcCanonical.hs | 2 +-
compiler/typecheck/TcErrors.hs | 34 +++--
compiler/typecheck/TcFlatten.hs | 78 ++++++------
compiler/typecheck/TcHsSyn.hs | 1 -
compiler/typecheck/TcInteract.hs | 13 +-
compiler/typecheck/TcMType.hs | 18 +--
compiler/typecheck/TcRnTypes.hs | 4 +-
compiler/typecheck/TcSMonad.hs | 138 ++++++++++++++-------
compiler/typecheck/TcSimplify.hs | 23 ++--
compiler/typecheck/TcType.hs | 40 +++---
compiler/typecheck/TcUnify.hs | 1 -
testsuite/tests/deriving/should_fail/T7148.stderr | 8 +-
testsuite/tests/gadt/T3169.stderr | 6 +-
testsuite/tests/gadt/T7558.stderr | 6 +-
.../tests/indexed-types/should_fail/T13674.hs | 56 +++++++++
.../tests/indexed-types/should_fail/T13674.stderr | 28 +++++
.../tests/indexed-types/should_fail/T4272.stderr | 7 +-
.../tests/indexed-types/should_fail/T9662.stderr | 4 +-
testsuite/tests/indexed-types/should_fail/all.T | 1 +
.../tests/typecheck/should_compile/FD3.stderr | 6 +-
.../tests/typecheck/should_compile/T9834.stderr | 4 +-
testsuite/tests/typecheck/should_fail/mc19.stderr | 6 +-
testsuite/tests/typecheck/should_fail/mc21.stderr | 6 +-
testsuite/tests/typecheck/should_fail/mc22.stderr | 6 +-
.../tests/typecheck/should_fail/tcfail191.stderr | 6 +-
.../tests/typecheck/should_fail/tcfail193.stderr | 6 +-
26 files changed, 321 insertions(+), 187 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 8dc6d645fc3384b3b8ded0578939f5c855dd2ed5
More information about the ghc-commits
mailing list