GHC 9.4.2/Cabal 3.8.1.0: `PackageImports` with `reexported-modules`, problem
Summary
I have reported the same issue in the repository of Cabal (the library) and it has been suggested there that it may be a bug in GHC 9.4.2. The problem has been reproduced with Stack and Cabal (the tool). The problem is most easily described by the steps to produce it, below.
Steps to reproduce
I have a library in package my-package-B
which exposes module LibB
. I have a library in package my-package-A
which build-depends
on my-package-B
and has reexported-modules
LibB
.
Finally, I have an executable in package my-package-C
which build-depends
on my-package-A
(only), and has Main.hs
:
{-# LANGUAGE PackageImports #-}
module Main (main) where
import "my-package-A" LibB (someFuncB)
main :: IO ()
main = print someFuncB
With stack --resolver ghc-9.2.4 build
, it all builds as expected.
However, with stack --resolver ghc-9.4.2 build
, and all else equal, the build fails with Cabal message:
my-package-C> app\Main.hs:6:1: error:
my-package-C> Could not find module ‘LibB’
my-package-C> Perhaps you meant
my-package-C> LibB (from my-package-A-0.1.0.0, reexporting LibB)
my-package-C> LibA (from my-package-A-0.1.0.0)
my-package-C> |
my-package-C> 6 | import "my-package-A" LibB (someFuncB)
my-package-C> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I can't make sense of the error message. I've requested LibB
be imported from package my-package-A
and I'm told it can't be found but perhaps I mean LibB
reexported by my-package-A
?
However, if I change (only) Main.hs
to (no package-qualified import):
module Main (main) where
import LibB (someFuncB)
main :: IO ()
main = print someFuncB
stack --resolver ghc-9.4.2 build
now works! That is why I think it is a bug.
Environment
- GHC 9.4.2
- Windows 11
- x86_64