[commit: ghc] master: Make use of boot TyThings during typechecking. (6998772)
git at git.haskell.org
git at git.haskell.org
Fri Dec 1 13:38:34 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/6998772043a7f0b0360116eb5ffcbaa5630b21fb/ghc
>---------------------------------------------------------------
commit 6998772043a7f0b0360116eb5ffcbaa5630b21fb
Author: Edward Z. Yang <ezyang at fb.com>
Date: Sun Oct 29 20:15:07 2017 -0400
Make use of boot TyThings during typechecking.
Summary:
Suppose that you are typechecking A.hs, which transitively imports,
via B.hs, A.hs-boot. When we poke on B.hs and discover that it
has a reference to a type from A, what TyThing should we wire
it up with? Clearly, if we have already typechecked A, we
should use the most up-to-date TyThing: the one we freshly
generated when we typechecked A. But what if we haven't typechecked
it yet?
For the longest time, GHC adopted the policy that this was
*an error condition*; that you MUST NEVER poke on B.hs's reference
to a thing defined in A.hs until A.hs has gotten around to checking
this. However, actually ensuring this is the case has proven
to be a bug farm. The problem was especially poignant with
type family consistency checks, which eagerly happen before
any typechecking takes place.
This patch takes a different strategy: if we ever try to access
an entity from A which doesn't exist, we just fall back on the
definition of A from the hs-boot file. This means that you may
end up with a mix of A.hs and A.hs-boot TyThings during the
course of typechecking.
Signed-off-by: Edward Z. Yang <ezyang at fb.com>
Test Plan: validate
Reviewers: simonpj, bgamari, austin, goldfire
Subscribers: thomie, rwbarton
GHC Trac Issues: #14396
Differential Revision: https://phabricator.haskell.org/D4154
>---------------------------------------------------------------
6998772043a7f0b0360116eb5ffcbaa5630b21fb
compiler/iface/TcIface.hs | 65 +++++++----
compiler/rename/RnSource.hs | 120 ---------------------
compiler/typecheck/FamInst.hs | 78 +++-----------
compiler/typecheck/TcRnDriver.hs | 4 +-
compiler/typecheck/TcRnMonad.hs | 1 -
compiler/typecheck/TcRnTypes.hs | 7 --
compiler/typecheck/TcTyClsDecls.hs | 4 -
testsuite/tests/typecheck/should_compile/T14396.hs | 4 +
.../tests/typecheck/should_compile/T14396.hs-boot | 2 +
.../tests/typecheck/should_compile/T14396a.hs | 5 +
.../tests/typecheck/should_compile/T14396b.hs | 4 +
.../A.hs => typecheck/should_compile/T14396f.hs} | 2 +-
testsuite/tests/typecheck/should_compile/all.T | 1 +
.../tests/typecheck/should_fail/T12042.stderr | 10 +-
14 files changed, 85 insertions(+), 222 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 6998772043a7f0b0360116eb5ffcbaa5630b21fb
More information about the ghc-commits
mailing list