[commit: ghc] ghc-8.6: Add nakedSubstTy and use it in TcHsType.tcInferApps (cfc4afa)
git at git.haskell.org
git at git.haskell.org
Thu Jul 12 21:07:06 UTC 2018
Repository : ssh://git@git.haskell.org/ghc
On branch : ghc-8.6
Link : http://ghc.haskell.org/trac/ghc/changeset/cfc4afad16d0eb99d5576cd998bcf473a1bc2af5/ghc
>---------------------------------------------------------------
commit cfc4afad16d0eb99d5576cd998bcf473a1bc2af5
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date: Mon Jul 9 17:29:22 2018 +0100
Add nakedSubstTy and use it in TcHsType.tcInferApps
This was a tricky one.
During type checking we maintain TcType:
Note [The well-kinded type invariant]
That is, types are well-kinded /without/ zonking.
But in tcInferApps we were destroying that invariant by calling
substTy, which in turn uses smart constructors, which eliminate
apparently-redundant Refl casts.
This is horribly hard to debug beause they really are Refls and
so it "ought" to be OK to discard them. But it isn't, as the
above Note describes in some detail.
Maybe we should review the invariant? But for now I just followed
it, tricky thought it is.
This popped up because (for some reason) when I fixed Trac #15343,
that exposed this bug by making test polykinds/T14174a fail (in
Trac #14174 which indeed has the same origin).
So this patch fixes a long standing and very subtle bug.
One interesting point: I defined nakedSubstTy in a few lines by
using the generic mapType stuff. I note that the "normal"
TyCoRep.substTy does /not/ use mapType. But perhaps it should:
substTy has lots of $! strict applications in it, and they could
all be eliminated just by useing the StrictIdentity monad. And
that'd make it much easier to experiment with switching between
strict and lazy versions.
(cherry picked from commit 5067b205a8abb5a9f98335d3a929f647c88c0aa2)
>---------------------------------------------------------------
cfc4afad16d0eb99d5576cd998bcf473a1bc2af5
compiler/typecheck/TcHsType.hs | 20 +++++---
compiler/typecheck/TcType.hs | 108 ++++++++++++++++++++++++++++++-----------
2 files changed, 94 insertions(+), 34 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 cfc4afad16d0eb99d5576cd998bcf473a1bc2af5
More information about the ghc-commits
mailing list