Skip to content

GHCi doesn't fully load previously broken modules

Scenario:

I have a project with three modules: Mod1, Mod2 and Mod3. Mod3 calls an undefined function and so shouldn't load. I call GHCi as

ghci Mod3.hs

The output looks like this:

GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help Loading package base ... linking ... done. [1 of 3] Compiling Mod1 ( Mod1.hs, interpreted ) [2 of 3] Compiling Mod2 ( Mod2.hs, interpreted ) [3 of 3] Compiling Mod3 ( Mod3.hs, interpreted ) Mod3.hs:6:6: Not in scope: `foo'

Mod3.hs:6:12: Not in scope: `barf' Failed, modules loaded: Mod2, Mod1.

The problem comes when I edit the file using GHCi's :e command and then reload with :r. The output looks like this (which is strange in itself, because the modules are listed in the wrong order):

  • Mod2> :r

[3 of 3] Compiling Mod3 ( Mod3.hs, interpreted ) Ok, modules loaded: Mod2, Mod3, Mod1.

The problem is this: when I call a function from Mod3 from the GHCi toplevel, I get a "not in scope" error. I can call the function as "Mod3.<function name>" but "Mod3" does not show up in GHCi's tab completion. I don't believe that this is the correct behavior.

Trac metadata
Trac field Value
Version 6.8.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component GHCi
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system Unknown
Architecture Unknown
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information