Misleading error message when trying to import a module from the wrong version of a package
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
**Describe the feature request**
I recently ran into an issue where `cabal` had resolved the `sdl2` package to a really old version since I hadn't specified the bounds for the `sdl2` dependency. I was trying to import a module that exists only in newer versions of the package and then I was greeted with the following error:
```
app/Main.hs:5:1: error: [GHC-87110]
Could not load module ‘SDL’.
It is a member of the hidden package ‘sdl2-2.5.5.0’.
Perhaps you need to add ‘sdl2’ to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.
|
5 | import SDL
| ^^^^^^^
```
It took me a while to figure out that the version of `sdl2` that cabal was using was actually `1.2.0` and adding explicit bounds to `sdl2` fixed the issue.
I think this error message could be improved to something like this:
```
app/Main.hs:5:1: error: [GHC-87110]
Could not load module ‘SDL’.
It is a member of the package `sdl2-2.5.5.0`, but you're currently using `sdl2-1.2.0`.
Perhaps you need to add explicit bounds to the `sdl2` dependency in your .cabal file.
Use -v to see a list of the files searched for.
|
5 | import SDL
| ^^^^^^^
```
Contributor guide
Research direction
Reproduce the GHC-87110 diagnostic from app/Main.hs with a .cabal file that resolves sdl2 to an older version while importing a module available only in a newer version. Start by tracing the package-resolution and hidden-package diagnostic paths described in the report. Done means the error distinguishes the selected package version from the version containing the module and recommends explicit dependency bounds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100