diff options
author | Roland Senn <rsx@bluewin.ch> | 2018-11-17 12:22:23 +0100 |
---|---|---|
committer | Krzysztof Gogolewski <krz.gogolewski@gmail.com> | 2018-11-17 13:51:58 +0100 |
commit | 921fd890abe0e7267962c9439098b03c94ebdb9b (patch) | |
tree | d3c70d86ea798e57540e3bcec8e6120128dedd94 /ghc | |
parent | 65517979adf03a1fa5d33d34e419e7dfc9444002 (diff) | |
download | haskell-921fd890abe0e7267962c9439098b03c94ebdb9b.tar.gz |
Fix #12525: Remove derived bindings from the TyThings from getBindings
Summary:
Remove derived OccNames from the list of TyThings returned by the function GHC.getBindings.
Therefore the output of the `:show bindings `command will not contain names generated by GHC.
Test Plan: make test TEST=T12525
Reviewers: austin, hvr, alanz, angerman, thomie, bgamari, osa1
Reviewed By: osa1
Subscribers: simonpj, osa1, rwbarton, carter
GHC Trac Issues: #12525
Differential Revision: https://phabricator.haskell.org/D5326
Diffstat (limited to 'ghc')
-rw-r--r-- | ghc/GHCi/UI.hs | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs index bfcaabf5e7..3de49b4c25 100644 --- a/ghc/GHCi/UI.hs +++ b/ghc/GHCi/UI.hs @@ -2927,10 +2927,12 @@ showBindings :: GHCi () showBindings = do bindings <- GHC.getBindings (insts, finsts) <- GHC.getInsts - docs <- mapM makeDoc (reverse bindings) - -- reverse so the new ones come last let idocs = map GHC.pprInstanceHdr insts fidocs = map GHC.pprFamInst finsts + binds = filter (not . isDerivedOccName . getOccName) bindings -- #12525 + -- See Note [Filter bindings] + docs <- mapM makeDoc (reverse binds) + -- reverse so the new ones come last mapM_ printForUserPartWay (docs ++ idocs ++ fidocs) where makeDoc (AnId i) = pprTypeAndContents i @@ -2951,6 +2953,29 @@ showBindings = do printTyThing :: TyThing -> GHCi () printTyThing tyth = printForUser (pprTyThing showToHeader tyth) +{- +Note [Filter bindings] +~~~~~~~~~~~~~~~~~~~~~~ + +If we don't filter the bindings returned by the function GHC.getBindings, +then the :show bindings command will also show unwanted bound names, +internally generated by GHC, eg: + $tcFoo :: GHC.Types.TyCon = _ + $trModule :: GHC.Types.Module = _ . + +The filter was introduced as a fix for Trac #12525 [1]. Comment:1 [2] to this +ticket contains an analysis of the situation and suggests the solution +implemented above. + +The same filter was also implemented to fix Trac #11051 [3]. See the +Note [What to show to users] in compiler/main/InteractiveEval.hs + +[1] https://ghc.haskell.org/trac/ghc/ticket/12525 +[2] https://ghc.haskell.org/trac/ghc/ticket/12525#comment:1 +[3] https://ghc.haskell.org/trac/ghc/ticket/11051 +-} + + showBkptTable :: GHCi () showBkptTable = do st <- getGHCiState |