Skip to content

Commit

Permalink
Add a test reproducing the import+unload problem reported by snoyberg
Browse files Browse the repository at this point in the history
I appears GHC does not unload modules if the error is in the import section.
Possibly, the reasoning goes that if module dependencies are wrong then
the module name can be wrong as well, so it's not clear which module to unload
(GHC does not equate file names with module names and not always checks
that they match). Will investigate further.
  • Loading branch information
Mikolaj authored and edsko committed Mar 7, 2013
1 parent f2e5603 commit 0b02e3a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/ghc-errors.hs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,26 @@ syntheticTests =
-- is never comipiled, so it's not invalidated.
assEq "wrong3" ["A", "A2", "A3", "XXX"]
)
, ( "Maintain list of compiled modules III"
, withConfiguredSession defOpts $ \session -> do
let assEq name goodMods =
assertEqual name (sort goodMods)
=<< (liftM sort $ getLoadedModules session)
updateSessionD session (loadModule "A.hs" "a = 5") 1
assEq "1 [A]" ["A"]
updateSessionD session (loadModule "A.hs" "a = 5 + True") 1
assEq "1 []" []
updateSessionD session (loadModule "A.hs" "a = 5") 1
assEq "2 [A]" ["A"]
updateSessionD session (loadModule "A.hs" "a = 5 + wrong") 1
assEq "2 []" []
updateSessionD session (loadModule "A.hs" "a = 5") 1
assEq "3 [A]" ["A"]
updateSessionD session (loadModule "A.hs" "import WRONG\na = 5") 1
assEq "3 [A]; wrong imports do not unload old modules" ["A"]
updateSessionD session (loadModule "A.hs" "a = 5 + True") 1
assEq "3 []" []
)
, ( "Duplicate shutdown"
, withConfiguredSession defOpts $ \session ->
-- withConfiguredSession will shutdown the session as well
Expand Down

0 comments on commit 0b02e3a

Please sign in to comment.