Fix suggestions for unbound variables (#11680)
authorJason Eisenberg <jasoneisenberg@gmail.com>
Sun, 10 Apr 2016 17:17:46 +0000 (19:17 +0200)
committerBen Gamari <ben@smart-cactus.org>
Sun, 10 Apr 2016 20:58:28 +0000 (22:58 +0200)
commit470d4d5b8e7cbcc176b1f3ac26ce0d95acd35a78
tree536e3f294da6c76878c1997d28508402b0b4c9cc
parent5a1add134fdb2ab4d91b0f66de1dc89f0cd69354
Fix suggestions for unbound variables (#11680)

When the typechecker generates the error message for an out-of-scope
variable, it now uses the GlobalRdrEnv with respect to which the
variable is unbound, not the GlobalRdrEnv which is available at the time
the error is reported.  Doing so ensures we do not provide suggestions
which themselves are out-of-scope (because they are bound in a later
inter-splice group).

Nonetheless, we do note in the error message if an unambiguous, exact
match to the out-of-scope variable is found in a later inter-splice
group, and we specify where that match is not in scope.

Test Plan: ./validate

Reviewers: goldfire, austin, bgamari

Reviewed By: goldfire

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2000

GHC Trac Issues: #11680
17 files changed:
compiler/basicTypes/OccName.hs
compiler/basicTypes/RdrName.hs
compiler/deSugar/DsMeta.hs
compiler/hsSyn/HsExpr.hs
compiler/rename/RnExpr.hs
compiler/rename/RnSource.hs
compiler/rename/RnTypes.hs
compiler/typecheck/TcCanonical.hs
compiler/typecheck/TcErrors.hs
compiler/typecheck/TcExpr.hs
compiler/typecheck/TcHsSyn.hs
compiler/typecheck/TcRnDriver.hs
compiler/typecheck/TcRnMonad.hs
compiler/typecheck/TcRnTypes.hs
testsuite/tests/th/T11680.hs [new file with mode: 0644]
testsuite/tests/th/T11680.stderr [new file with mode: 0644]
testsuite/tests/th/all.T