haskell / cabal

Official upstream development repository for Cabal and cabal-install
https://haskell.org/cabal
Other
1.61k stars 691 forks source link

Using :load from within `cabal repl` can cause `-Wmissing-home-modules` to go haywire #4711

Open RyanGlScott opened 7 years ago

RyanGlScott commented 7 years ago

I often cabal repl into a project and then :load into another module so that I can test changes from that project on the module. However, this workflow confuses cabal-install's integration with GHC's -Wmissing-home-modules flag. To see what I mean, first prepare this Haskell file:

module Foo where

import Control.Monad.Cont

And then do the following:

$ cabal get mtl-2.2.1
Unpacking to mtl-2.2.1/
$ cd mtl-2.2.1/
$ cabal repl
Resolving dependencies...
Configuring mtl-2.2.1...
Preprocessing library for mtl-2.2.1..
GHCi, version 8.2.1: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[ 1 of 22] Compiling Control.Monad.Cont.Class ( Control/Monad/Cont/Class.hs, interpreted )
[ 2 of 22] Compiling Control.Monad.Error.Class ( Control/Monad/Error/Class.hs, interpreted )
[ 3 of 22] Compiling Control.Monad.Identity ( Control/Monad/Identity.hs, interpreted )
[ 4 of 22] Compiling Control.Monad.Reader.Class ( Control/Monad/Reader/Class.hs, interpreted )
[ 5 of 22] Compiling Control.Monad.State.Class ( Control/Monad/State/Class.hs, interpreted )
[ 6 of 22] Compiling Control.Monad.Trans ( Control/Monad/Trans.hs, interpreted )
[ 7 of 22] Compiling Control.Monad.State.Strict ( Control/Monad/State/Strict.hs, interpreted )
[ 8 of 22] Compiling Control.Monad.State.Lazy ( Control/Monad/State/Lazy.hs, interpreted )
[ 9 of 22] Compiling Control.Monad.State ( Control/Monad/State.hs, interpreted )
[10 of 22] Compiling Control.Monad.Reader ( Control/Monad/Reader.hs, interpreted )
[11 of 22] Compiling Control.Monad.List ( Control/Monad/List.hs, interpreted )
[12 of 22] Compiling Control.Monad.Except ( Control/Monad/Except.hs, interpreted )
[13 of 22] Compiling Control.Monad.Error ( Control/Monad/Error.hs, interpreted )
[14 of 22] Compiling Control.Monad.Cont ( Control/Monad/Cont.hs, interpreted )
[15 of 22] Compiling Control.Monad.Writer.Class ( Control/Monad/Writer/Class.hs, interpreted )
[16 of 22] Compiling Control.Monad.RWS.Class ( Control/Monad/RWS/Class.hs, interpreted )
[17 of 22] Compiling Control.Monad.RWS.Strict ( Control/Monad/RWS/Strict.hs, interpreted )
[18 of 22] Compiling Control.Monad.RWS.Lazy ( Control/Monad/RWS/Lazy.hs, interpreted )
[19 of 22] Compiling Control.Monad.RWS ( Control/Monad/RWS.hs, interpreted )
[20 of 22] Compiling Control.Monad.Writer.Lazy ( Control/Monad/Writer/Lazy.hs, interpreted )
[21 of 22] Compiling Control.Monad.Writer ( Control/Monad/Writer.hs, interpreted )
[22 of 22] Compiling Control.Monad.Writer.Strict ( Control/Monad/Writer/Strict.hs, interpreted )
Ok, 22 modules loaded.
λ> :l ../Foo.hs

<no location info>: warning: [-Wmissing-home-modules]
    These modules are needed for compilation but not listed in your .cabal file's other-modules: Control.Monad.Cont
                                                                                                 Control.Monad.Cont.Class
                                                                                                 Control.Monad.Trans
[1 of 4] Compiling Control.Monad.Cont.Class ( Control/Monad/Cont/Class.hs, interpreted )
[2 of 4] Compiling Control.Monad.Trans ( Control/Monad/Trans.hs, interpreted )
[3 of 4] Compiling Control.Monad.Cont ( Control/Monad/Cont.hs, interpreted )
[4 of 4] Compiling Foo              ( ../Foo.hs, interpreted )
Ok, 4 modules loaded.

Why should -Wmissing-home-modules be firing here?

$ cabal --version
cabal-install version 2.0.0.0
compiled using version 2.0.0.2 of the Cabal library
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.2.1
ulysses4ever commented 2 years ago

Still reproduces with cabal 3.6.