-Wunused-packages false negatives
Summary
Sometimes, removing the last import
for a dependency doesn't trigger -Wunused-package
. That's not that big of a deal by itself, but then later on, changing something unrelated might cause -Wunused-package
to start being triggered again. Sometimes when this happens, running stack purge
(to delete all GHC build artifacts) and building again goes back to it being a false negative.
In my current situation:
- I removed the last use of
Data.DList
fromdlist
in package A without removing it as a dependency, and GHC did not error with-Wunused-package
- I started working on a branch, where I didn't touch package A, but I edited package B which package A depends on
- Note: package B doesn't have
dlist
as a dependency, but it does depend on package C, which does havedlist
as a dependency
- Note: package B doesn't have
- Suddenly package A starts failing with
-Wunused-package
- Cleaning my build environment with
stack purge
and rebuilding causes package A to stop erroring again (as a false negative)
I know the docs say GHC makes a best effort to find unused packages, and I know there are bound to be times where it doesn't find all of them. That being said, there are a few possible outcomes I can see for this ticket:
- Close as won't fix
- Fix the minimal repro as an incremental improvement to the warning
- Keep this issue open as a central hub for all
-Wunused-package
false negative reports - Add documentation as to when you might see false negatives, and when those false negatives might start becoming true negatives
Steps to reproduce
Here's a minimal repro that shows the behavior I see, but it's different in that in my project, I didn't change parent
at all.
Expected behavior
In the minimal repro, -Wunused-packages
should be triggered regardless of whether Generic
is derived.
Environment
- GHC version used: 8.10.4
Optional:
- Operating System: MacOS
- System Architecture: