This flag stops ghci creating the special variable it
after evaluating an expression. This stops ghci leaking
as much memory when evaluating expressions. See Trac #14336
As I understand it another variable could bind it, ie let f = it and so if we remove the binding then f will break. There is no special logic for it, it is the same as any variable bound in ghci so it behaves the same when shadowed.
I'm not sure I understand why it is leaking. Surely we should be able to expunge the old binding after it is shadowed, no?
I'm not sure if you've seen this comment, but it surprised me the first time I read it: https://phabricator.haskell.org/diffusion/GHC/browse/master/compiler/main/HscTypes.hs;cf2c029ccdb967441c85ffb66073974fbdb20c20$1385
This leads to the following behavior:
$ ./inplace/bin/ghc-stage2 --interactive GHCi, version 8.5.20180114: http://www.haskell.org/ghc/ :? for help Prelude> 1 1 Prelude> 2 2 Prelude> 3 3 Prelude> 4 4 Prelude> 5 5 Prelude> Ghci Ghci1.it Ghci2.it Ghci3.it Ghci4.it Prelude> Ghci4.it 4 Prelude> Ghci3.it 3 Prelude> Ghci2.it 2 Prelude> Ghci1.it 1 Prelude>