GHCi: Don't remove shadowed bindings from typechecker scope.
ClosedPublic

Authored by mniip on Aug 8 2016, 9:13 PM.

Details

Summary

The shadowed out bindings are accessible via qualified names like Ghci1.foo.
Since they are accessable in the renamer the typechecker should be able to see them too.
As a consequence they show up in :show bindings.

This fixes T11547

Test Plan

Fixed current tests to accomodate to new stuff in :show bindings
Added a test that verifies that the typechecker doesn't crash

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
mniip updated this revision to Diff 8399.Aug 8 2016, 9:13 PM
mniip retitled this revision from to GHCi: Don't remove shadowed bindings from typechecker scope..
mniip updated this object.
mniip edited the test plan for this revision. (Show Details)
mniip edited edge metadata.Aug 8 2016, 9:14 PM
mniip updated the Trac tickets for this revision.
bgamari edited edge metadata.Aug 31 2016, 2:13 PM
bgamari added a subscriber: simonpj.

@simonpj, any objection to this?

simonpj accepted this revision.Sep 5 2016, 11:33 AM
simonpj added a reviewer: simonpj.

I'm ok with this. I don't think I fully understand all the consequences, but I don't want to stand in the way.

If Ghci1.foo and Ghci1.foo are both in scope, won't plain unqualified foo suddenly become ambiguous? If not why not? Please include a test to demonstrate that it's ok.

ghci> let foo x = x
ghci> let foo x = x+1
ghci> foo 4
This revision is now accepted and ready to land.Sep 5 2016, 11:33 AM
bgamari added a comment.EditedSep 5 2016, 2:08 PM

I suppose the problem is that today users tend to think of the GHCi prompt as being a do block. In a do block it's not uncommon to use shadowing. Changing the behavior here may be surprising to existing users. I'm not sure what the right solution is here.

@mniip, any comments on the point I raised above?

This revision was automatically updated to reflect the committed changes.