Commit cd85dc84 authored by Matthew Pickering's avatar Matthew Pickering Committed by Ben Gamari

Make sure record pattern synonym selectors are in scope in GHCi.

Beforehand, when a record pattern synonym was defined in GHCi
the selectors would not be in scope. This is because of `is_sub_bndr`
in `HscTypes.icExtendGblRdrEnv` was throwing away the selectors.

This was broken by the fix to #10520 but it is easy to resolve.

Reviewers: austin, bgamari, simonpj

Reviewed By: simonpj

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11985
parent ea34f565
......@@ -1504,9 +1504,9 @@ icExtendGblRdrEnv env tythings
| is_sub_bndr thing
= env
| otherwise
= foldl extendGlobalRdrEnv env1 (localGREsFromAvail avail)
= foldl extendGlobalRdrEnv env1 (concatMap localGREsFromAvail avail)
env1 = shadowNames env (availNames avail)
env1 = shadowNames env (concatMap availNames avail)
avail = tyThingAvailInfo thing
-- Ugh! The new_tythings may include record selectors, since they
......@@ -1829,19 +1829,21 @@ tyThingsTyCoVars tts =
-- | The Names that a TyThing should bring into scope. Used to build
-- the GlobalRdrEnv for the InteractiveContext.
tyThingAvailInfo :: TyThing -> AvailInfo
tyThingAvailInfo :: TyThing -> [AvailInfo]
tyThingAvailInfo (ATyCon t)
= case tyConClass_maybe t of
Just c -> AvailTC n (n : map getName (classMethods c)
Just c -> [AvailTC n (n : map getName (classMethods c)
++ map getName (classATs c))
[] ]
where n = getName c
Nothing -> AvailTC n (n : map getName dcs) flds
Nothing -> [AvailTC n (n : map getName dcs) flds]
where n = getName t
dcs = tyConDataCons t
flds = tyConFieldLabels t
tyThingAvailInfo (AConLike (PatSynCon p))
= map patSynAvail ((getName p) : map flSelector (patSynFieldLabels p))
tyThingAvailInfo t
= avail (getName t)
= [avail (getName t)]
:set -XPatternSynonyms
pattern Point{x, y} = (x, y)
(1, 2) { x = 3}
......@@ -12,4 +12,5 @@ test('match-unboxed', normal, compile_and_run, [''])
test('unboxed-wrapper', normal, compile_and_run, [''])
test('records-run', normal, compile_and_run, [''])
test('ghci', just_ghci, ghci_script, ['ghci.script'])
test('T11985', just_ghci, ghci_script, ['T11985.script'])
test('T11224', normal, compile_and_run, [''])
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment