summaryrefslogtreecommitdiff
path: root/compiler/main/InteractiveEval.hs
diff options
context:
space:
mode:
authorAdam Gundry <adam@well-typed.com>2016-02-01 16:41:03 +0100
committerBen Gamari <ben@smart-cactus.org>2016-02-01 22:12:52 +0100
commitdd0b7c78f64f2498594d3ef89d3bf884402f14d9 (patch)
tree792e32b256531c2593e37de30a80f43692e2ded0 /compiler/main/InteractiveEval.hs
parent73293109645efe42bf3fdf3335f4ab7cef39001b (diff)
downloadhaskell-dd0b7c78f64f2498594d3ef89d3bf884402f14d9.tar.gz
Avoid mangled/derived names in GHCi autocomplete (fixes #11328)
This changes `getRdrNamesInScope` to use field labels rather than selector names for fields from modules with `DuplicateRecordFields` enabled. Moreover, it filters out derived names (e.g. type representation bindings) that shouldn't show up in autocomplete. Test Plan: New test ghci/should_run/T11328 Reviewers: kolmodin, austin, bgamari, simonpj Reviewed By: bgamari, simonpj Subscribers: simonpj, thomie Differential Revision: https://phabricator.haskell.org/D1870 GHC Trac Issues: #11328
Diffstat (limited to 'compiler/main/InteractiveEval.hs')
-rw-r--r--compiler/main/InteractiveEval.hs5
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/main/InteractiveEval.hs b/compiler/main/InteractiveEval.hs
index b66a4f8c82..ac4c60e735 100644
--- a/compiler/main/InteractiveEval.hs
+++ b/compiler/main/InteractiveEval.hs
@@ -800,13 +800,16 @@ getNamesInScope :: GhcMonad m => m [Name]
getNamesInScope = withSession $ \hsc_env -> do
return (map gre_name (globalRdrEnvElts (ic_rn_gbl_env (hsc_IC hsc_env))))
+-- | Returns all 'RdrName's in scope in the current interactive
+-- context, excluding any that are internally-generated.
getRdrNamesInScope :: GhcMonad m => m [RdrName]
getRdrNamesInScope = withSession $ \hsc_env -> do
let
ic = hsc_IC hsc_env
gbl_rdrenv = ic_rn_gbl_env ic
gbl_names = concatMap greRdrNames $ globalRdrEnvElts gbl_rdrenv
- return gbl_names
+ -- Exclude internally generated names; see e.g. Trac #11328
+ return (filter (not . isDerivedOccName . rdrNameOcc) gbl_names)
-- | Parses a string as an identifier, and returns the list of 'Name's that