ghc reports package-id in unused imports warning instead the package name+version+id
Summary
From https://github.com/haskell/cabal/issues/7209#issuecomment-1080118466 ghc reports bad package name in unused imports warning when the package-id name segment does not match the package name
Steps to reproduce
-
cabal build -v3
a project with any dependency containing vowels andghc-options: -Wunused-packages -Werror=unused-packages
- check the ghc call made by cabal pass the package id removing vowels from the package name
- for the
ieee
package it would be like-package-id -0.7-c9bfa6bf
- for the
- check the v2 store package db has the complete package name for such package id:
# ghc-pkg --package-db ~/.cabal/store/ghc-9.2.2/package.db describe ieee | head -n 5
name: ieee
version: 0.7
visibility: public
id: -0.7-c9bfa6bf
key: -0.7-c9bfa6bf
- and check the unused package warning uses the package-id instead the full package name plus version:
<no location info>: warning: [-Wunused-packages]
The following packages were specified via -package or -package-id flags,
but were not needed for compilation:
- -0.7-c9bfa6bf
- the behaviour is not reproduced in windows, where package names are also shortened by cabal in the package id, see https://github.com/haskell/cabal/issues/7209#issuecomment-1080327599
- from the ghc call made by cabal we derive the bug is in the ghc side
Expected behavior
- the error message should use the full package name + package version from package-db
<no location info>: warning: [-Wunused-packages]
The following packages were specified via -package or -package-id flags,
but were not needed for compilation:
- ieee-0.7
Environment
- GHC version used: 8.10.7, 9.2.2
Optional:
- Operating System: macos
- System Architecture: anyñ