Commit 98c7749c authored by Ömer Sinan Ağacan's avatar Ömer Sinan Ağacan

Revert "GHCi: Don't remove shadowed bindings from typechecker scope."

This reverts commit 59d7ee53 and enables
the test for #14052.

(See #14052 for the discussion)

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14052

Differential Revision: https://phabricator.haskell.org/D4478
parent d99a65a8
...@@ -1641,7 +1641,7 @@ extendInteractiveContext ictxt new_tythings new_cls_insts new_fam_insts defaults ...@@ -1641,7 +1641,7 @@ extendInteractiveContext ictxt new_tythings new_cls_insts new_fam_insts defaults
= ictxt { ic_mod_index = ic_mod_index ictxt + 1 = ictxt { ic_mod_index = ic_mod_index ictxt + 1
-- Always bump this; even instances should create -- Always bump this; even instances should create
-- a new mod_index (Trac #9426) -- a new mod_index (Trac #9426)
, ic_tythings = new_tythings ++ ic_tythings ictxt , ic_tythings = new_tythings ++ old_tythings
, ic_rn_gbl_env = ic_rn_gbl_env ictxt `icExtendGblRdrEnv` new_tythings , ic_rn_gbl_env = ic_rn_gbl_env ictxt `icExtendGblRdrEnv` new_tythings
, ic_instances = ( new_cls_insts ++ old_cls_insts , ic_instances = ( new_cls_insts ++ old_cls_insts
, new_fam_insts ++ fam_insts ) , new_fam_insts ++ fam_insts )
...@@ -1651,6 +1651,8 @@ extendInteractiveContext ictxt new_tythings new_cls_insts new_fam_insts defaults ...@@ -1651,6 +1651,8 @@ extendInteractiveContext ictxt new_tythings new_cls_insts new_fam_insts defaults
, ic_fix_env = fix_env -- See Note [Fixity declarations in GHCi] , ic_fix_env = fix_env -- See Note [Fixity declarations in GHCi]
} }
where where
new_ids = [id | AnId id <- new_tythings]
old_tythings = filterOut (shadowed_by new_ids) (ic_tythings ictxt)
-- Discard old instances that have been fully overridden -- Discard old instances that have been fully overridden
-- See Note [Override identical instances in GHCi] -- See Note [Override identical instances in GHCi]
...@@ -1662,10 +1664,17 @@ extendInteractiveContextWithIds :: InteractiveContext -> [Id] -> InteractiveCont ...@@ -1662,10 +1664,17 @@ extendInteractiveContextWithIds :: InteractiveContext -> [Id] -> InteractiveCont
extendInteractiveContextWithIds ictxt new_ids extendInteractiveContextWithIds ictxt new_ids
| null new_ids = ictxt | null new_ids = ictxt
| otherwise = ictxt { ic_mod_index = ic_mod_index ictxt + 1 | otherwise = ictxt { ic_mod_index = ic_mod_index ictxt + 1
, ic_tythings = new_tythings ++ ic_tythings ictxt , ic_tythings = new_tythings ++ old_tythings
, ic_rn_gbl_env = ic_rn_gbl_env ictxt `icExtendGblRdrEnv` new_tythings } , ic_rn_gbl_env = ic_rn_gbl_env ictxt `icExtendGblRdrEnv` new_tythings }
where where
new_tythings = map AnId new_ids new_tythings = map AnId new_ids
old_tythings = filterOut (shadowed_by new_ids) (ic_tythings ictxt)
shadowed_by :: [Id] -> TyThing -> Bool
shadowed_by ids = shadowed
where
shadowed id = getOccName id `elemOccSet` new_occs
new_occs = mkOccSet (map getOccName ids)
setInteractivePackage :: HscEnv -> HscEnv setInteractivePackage :: HscEnv -> HscEnv
-- Set the 'thisPackage' DynFlag to 'interactive' -- Set the 'thisPackage' DynFlag to 'interactive'
......
...@@ -23,13 +23,6 @@ _exception = SomeException ...@@ -23,13 +23,6 @@ _exception = SomeException
"foo" "foo"
"CallStack (from HasCallStack): "CallStack (from HasCallStack):
error, called at Test7.hs:2:18 in main:Main") error, called at Test7.hs:2:18 in main:Main")
Ghci1._exception :: SomeException = SomeException
(ErrorCallWithLocation
"foo"
"CallStack (from HasCallStack):
error, called at Test7.hs:<line>:<column> in <package-id>:Main")
Ghci2._result :: a = _
Ghci3._result :: IO a = _
_result :: a = _ _result :: a = _
_exception :: SomeException = SomeException _exception :: SomeException = SomeException
(ErrorCallWithLocation (ErrorCallWithLocation
......
...@@ -12,7 +12,6 @@ Logged breakpoint at Test3.hs:2:22-31 ...@@ -12,7 +12,6 @@ Logged breakpoint at Test3.hs:2:22-31
_result :: [a] _result :: [a]
f :: t -> a f :: t -> a
xs :: [t] xs :: [t]
Ghci1._result :: [a] = _
xs :: [t] = [] xs :: [t] = []
f :: t -> a = _ f :: t -> a = _
_result :: [a] = _ _result :: [a] = _
...@@ -20,10 +19,7 @@ Logged breakpoint at Test3.hs:2:18-20 ...@@ -20,10 +19,7 @@ Logged breakpoint at Test3.hs:2:18-20
_result :: a _result :: a
f :: Integer -> a f :: Integer -> a
x :: Integer x :: Integer
Ghci1._result :: [a] = _
xs :: [t] = [] xs :: [t] = []
Ghci2.f :: t -> a = _
Ghci2._result :: [a] = _
x :: Integer = 2 x :: Integer = 2
f :: Integer -> a = _ f :: Integer -> a = _
_result :: a = _ _result :: a = _
......
...@@ -12,7 +12,6 @@ Logged breakpoint at Test3.hs:2:22-31 ...@@ -12,7 +12,6 @@ Logged breakpoint at Test3.hs:2:22-31
_result :: [a] _result :: [a]
f :: t -> a f :: t -> a
xs :: [t] xs :: [t]
Ghci1._result :: [a] = _
xs :: [t] = [] xs :: [t] = []
f :: t -> a = _ f :: t -> a = _
_result :: [a] = _ _result :: [a] = _
...@@ -20,10 +19,7 @@ Logged breakpoint at Test3.hs:2:18-20 ...@@ -20,10 +19,7 @@ Logged breakpoint at Test3.hs:2:18-20
_result :: a _result :: a
f :: Integer -> a f :: Integer -> a
x :: Integer x :: Integer
Ghci1._result :: [a] = _
xs :: [t] = [] xs :: [t] = []
Ghci2.f :: t -> a = _
Ghci2._result :: [a] = _
x :: Integer = 2 x :: Integer = 2
f :: Integer -> a = _ f :: Integer -> a = _
_result :: a = _ _result :: a = _
......
foo = foo
:t Ghci1.foo
foo = foo
:t Ghci2.foo
:t Ghci1.foo
data Foo = Foo | Bar
data Foo = Bar
:t Foo
:t Ghci3.Bar
Ghci1.foo :: t
Ghci2.foo :: t
Ghci1.foo :: t
Foo :: Ghci3.Foo
Ghci3.Bar :: Ghci3.Foo
test :: Integer = 0 test :: Integer = 0
test = 0 test = 0
test :: Integer = 0 test :: Integer = 0
Ghci1.test :: Integer = 0
test :: [Char] = _ test :: [Char] = _
test = "test" test = "test"
Ghci1.test :: Integer = 0
test :: [Char] = "test" test :: [Char] = "test"
...@@ -238,7 +238,6 @@ test('T11376', normal, ghci_script, ['T11376.script']) ...@@ -238,7 +238,6 @@ test('T11376', normal, ghci_script, ['T11376.script'])
test('T12007', normal, ghci_script, ['T12007.script']) test('T12007', normal, ghci_script, ['T12007.script'])
test('T11975', normal, ghci_script, ['T11975.script']) test('T11975', normal, ghci_script, ['T11975.script'])
test('T10963', normal, ghci_script, ['T10963.script']) test('T10963', normal, ghci_script, ['T10963.script'])
test('T11547', normal, ghci_script, ['T11547.script'])
test('T11721', normal, ghci_script, ['T11721.script']) test('T11721', normal, ghci_script, ['T11721.script'])
test('T12520', normal, ghci_script, ['T12520.script']) test('T12520', normal, ghci_script, ['T12520.script'])
test('T12091', [extra_run_opts('-fobject-code')], ghci_script, test('T12091', [extra_run_opts('-fobject-code')], ghci_script,
......
...@@ -553,7 +553,6 @@ test('T13623', ...@@ -553,7 +553,6 @@ test('T13623',
test('T14052', test('T14052',
[stats_num_field('bytes allocated', [stats_num_field('bytes allocated',
[ (wordsize(64), 2785811496, 10) ]), [ (wordsize(64), 2346183840, 10) ])],
expect_broken(14052)],
ghci_script, ghci_script,
['T14052.script']) ['T14052.script'])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment