[commit: ghc] master: Better error reporting for inaccessible code (ff29fc8)

git at git.haskell.org git at git.haskell.org
Fri Aug 24 16:20:44 UTC 2018


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

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

>---------------------------------------------------------------

commit ff29fc84c03c800cfa04c2a00eb8edf6fa5f4183
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Fri Aug 24 16:40:28 2018 +0100

    Better error reporting for inaccessible code
    
    This patch fixes Trac #15558.  There turned out to be
    two distinct problems
    
    * In TcExpr.tc_poly_expr_nc we had
    
        tc_poly_expr_nc (L loc expr) res_ty
          = do { traceTc "tcPolyExprNC" (ppr res_ty)
               ; (wrap, expr')
                   <- tcSkolemiseET GenSigCtxt res_ty $ \ res_ty ->
                      setSrcSpan loc $
                        -- NB: setSrcSpan *after* skolemising,
                        -- so we get better skolem locations
                      tcExpr expr res_ty
    
      Putting the setSrcSpan inside the tcSkolemise means that
      the location on the Implication constraint is the /call/
      to the function rather than the /argument/ to the call,
      and that is really quite wrong.
    
      I don't know what Richard's comment NB means -- I moved the
      setSrcSpan outside, and the "binding site" info in error
      messages actually improved.
    
      The reason I found this is that it affects the span reported
      for Trac #15558.
    
    * In TcErrors.mkGivenErrorReporter we carefully munge the location
      for an insoluble Given constraint (Note [Inaccessible code]).
      But the 'implic' passed in wasn't necesarily the immediately-
      enclosing implication -- but for location-munging purposes
      it jolly well should be.
    
      Solution: use the innermost implication. This actually
      simplifies the code -- no need to pass an implication in to
      mkGivenErrorReporter.


>---------------------------------------------------------------

ff29fc84c03c800cfa04c2a00eb8edf6fa5f4183
 compiler/typecheck/TcErrors.hs                     | 42 ++++++++++++----------
 compiler/typecheck/TcExpr.hs                       |  6 ++--
 .../tests/dependent/should_fail/T14066d.stderr     |  2 +-
 testsuite/tests/gadt/T15558.hs                     | 14 ++++++++
 testsuite/tests/gadt/T15558.stderr                 |  9 +++++
 testsuite/tests/gadt/all.T                         |  1 +
 testsuite/tests/polykinds/T7594.stderr             |  2 +-
 .../tests/typecheck/should_fail/tcfail068.stderr   |  8 ++---
 .../tests/typecheck/should_fail/tcfail076.stderr   |  4 +--
 9 files changed, 58 insertions(+), 30 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 ff29fc84c03c800cfa04c2a00eb8edf6fa5f4183


More information about the ghc-commits mailing list