[commit: ghc] master: Make better "fake tycons" in error recovery (2f6069c)

git at git.haskell.org git at git.haskell.org
Fri Jun 15 11:13:03 UTC 2018

Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/2f6069ccf21d7be0e09016896238f417d2492ffa/ghc


commit 2f6069ccf21d7be0e09016896238f417d2492ffa
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Fri Jun 15 09:46:30 2018 +0100

    Make better "fake tycons" in error recovery
    Consider (Trac #15215)
      data T a = MkT ...
      data S a = ...T...MkT....
    If there is an error in the definition of 'T' we add a
    "fake type constructor" to the type environment, so that we
    can continue to typecheck 'S'.  But we /were not/ adding
    a fake anything for 'MkT' and so there was an internal
    error when we met 'MkT' in the body of 'S'.
    The fix is to add fake tycons for all the 'implicits' of 'T'.
    This is done by mk_fake_tc in TcTyClsDecls.checkValidTyCl,
    which now returns a /list/ of TyCons rather than just one.
    On the way I did some refactoring:
    * Rename TcTyDecls.tcAddImplicits to tcAddTyConsToGblEnv
      and make it /include/ the TyCons themeselves as well
      as their implicits
    * Some incidental refactoring about tcRecSelBinds. The main
      thing is that I've avoided creating a HsValBinds that we
      immediately decompose.  That meant moving some deck chairs
    NB: The new error message for the regression test T15215
    has the opaque error "Illegal constraint in a type:", flagged
    in Trac #14845.  But that's the fault of the latter ticket.
    The fix here not to blame.


 compiler/typecheck/TcBinds.hs                      | 11 +---
 compiler/typecheck/TcEnv.hs                        |  2 +-
 compiler/typecheck/TcInstDcls.hs                   | 12 ++--
 compiler/typecheck/TcPatSyn.hs                     |  8 +--
 compiler/typecheck/TcTyClsDecls.hs                 | 68 ++++++++++++++--------
 compiler/typecheck/TcTyDecls.hs                    | 52 ++++++++++-------
 testsuite/tests/dependent/should_fail/T15215.hs    | 12 ++++
 .../tests/dependent/should_fail/T15215.stderr      | 12 ++++
 testsuite/tests/dependent/should_fail/all.T        |  1 +
 9 files changed, 111 insertions(+), 67 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 2f6069ccf21d7be0e09016896238f417d2492ffa

More information about the ghc-commits mailing list