[commit: ghc] master: Treat out-of-scope variables as holes (fb7b692)

git at git.haskell.org git at git.haskell.org
Fri Jun 26 07:33:14 UTC 2015


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

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

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

commit fb7b6922573af76a954d939c85e6af7c39a19896
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Wed Jun 24 23:27:59 2015 +0100

    Treat out-of-scope variables as holes
    
    This patch implements the idea in Trac #10569.
    
    * An out-of-scope variable is treated as a typed expression
      hole.
    
    * That is, we don't report it in the type checker, not the
      renamer, and we when we do report it, we give its type.
    
    * Moreover, we can defer the error to runtime with
      -fdefer-typed-holes
    
    In implementation terms:
    
    * The renamer turns an unbound variable into a HsUnboundVar
    
    * The type checker emits a Hole constraint for a
      HsUnboundVar, and turns it back into a HsVar
    
    It was a bit painful to implement because a whole raft of
    error messages change slightly.  But there was absolutely
    nothing hard in principle.
    
    Holes are reported with a bunch of possibly-useful context,
    notably the "relevant bindings".  I found that this was
    distracting clutter in the very common case of a mis-typed
    variable that is only accidentally not in scope, so I've
    arranged to print the context information only for true holes,
    that is ones starting with an underscore.
    
    Unbound data constructors use in patterns, like
      f (D x) = x
    are still reportd by the renamer, and abort compilation
    before type checking.


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

fb7b6922573af76a954d939c85e6af7c39a19896
 compiler/deSugar/Coverage.hs      |  20 ++--
 compiler/deSugar/DsExpr.hs        |   2 +-
 compiler/hsSyn/HsExpr.hs          |  45 +++++----
 compiler/rename/RnEnv.hs          |  60 +++++++-----
 compiler/rename/RnExpr.hs         |  48 ++++++----
 compiler/typecheck/TcErrors.hs    | 195 +++++++++++++++++++++-----------------
 compiler/typecheck/TcExpr.hs      |  18 ++--
 compiler/typecheck/TcRnTypes.hs   |  27 +++---
 compiler/typecheck/TcRules.hs     |   5 +-
 compiler/typecheck/TcSMonad.hs    |   7 +-
 compiler/typecheck/TcSimplify.hs  |  17 ++--
 compiler/typecheck/TcType.hs      |  23 +++++
 docs/users_guide/glasgow_exts.xml |  41 +++++++-
 13 files changed, 313 insertions(+), 195 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 fb7b6922573af76a954d939c85e6af7c39a19896


More information about the ghc-commits mailing list