Skip to content
Snippets Groups Projects
Commit d095954b authored by Adam Gundry's avatar Adam Gundry Committed by Marge Bot
Browse files

Do not remove shadowed record selectors from interactive context (fixes #19322)

parent afc357d2
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,7 @@ import GHC.Core.Type
import GHC.Types.Avail
import GHC.Types.Fixity.Env
import GHC.Types.Id ( isRecordSelector )
import GHC.Types.Id.Info ( IdDetails(..) )
import GHC.Types.Name
import GHC.Types.Name.Env
......@@ -342,7 +343,9 @@ extendInteractiveContextWithIds ictxt new_ids
shadowed_by :: [Id] -> TyThing -> Bool
shadowed_by ids = shadowed
where
shadowed id = getOccName id `elemOccSet` new_occs
-- Keep record selectors because they might be needed by HasField (#19322)
shadowed (AnId id) | isRecordSelector id = False
shadowed tything = getOccName tything `elemOccSet` new_occs
new_occs = mkOccSet (map getOccName ids)
setInteractivePrintName :: InteractiveContext -> Name -> InteractiveContext
......
:set -XTypeApplications -XDataKinds
import GHC.Records
data X = X { name :: String }
data Y = Y { name :: String }
getField @"name" $ X "Tom"
"Tom"
......@@ -2,3 +2,4 @@ test('duplicaterecfldsghci01', combined_output, ghci_script, ['duplicaterecfldsg
test('overloadedlabelsghci01', combined_output, ghci_script, ['overloadedlabelsghci01.script'])
test('T13438', [expect_broken(13438), combined_output], ghci_script, ['T13438.script'])
test('GHCiDRF', [extra_files(['GHCiDRF.hs']), combined_output], ghci_script, ['GHCiDRF.script'])
test('T19322', combined_output, ghci_script, ['T19322.script'])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment