haskell / haskell/haskell-mode

Loading a file under test-suite fails when importing library

Open
#1,837 2 comments 2 reactions 0 assignees View on GitHub
Dominant language
Emacs Lisp
Stars
1.4k
Forks
354
Avg merge
5d 10h
Merged PRs (30d)
2

Description

When I load a file from a test-suite, I am getting suggestions to add dependencies to the cabal file that are already listed as dependencies in the test-suite.

Reproducer:
```
mkdir foo
cd foo
cabal init -n --lib --tests
```
We now add dependency `QuickCheck` to the testsuite.
```
echo " , QuickCheck" >> *.cabal
```
In Emacs,
- load `test/Main.hs`
- add line `import Test.QuickCheck`
- load the file into the haskell-mode with `C-c C-l`

This will suggest "**Add QuickCheck to foo.cabal? (y or n)**" and block until an answer is given. (Of course, we do not want to add anything to our cabal file because it is perfectly ok.)
The suggestion seems to be harvested from the error:
```
Could not load module ‘Test.QuickCheck’.
It is a member of the hidden package ‘QuickCheck-2.14.3’.
Perhaps you need to add ‘QuickCheck’ to the build-depends in your .cabal file.
```
haskell-mode seems to load the file in the wrong context.

1. I suspect loading files from test-suites is not supported yet. It would be good if the haskell-mode would warn about the missing feature (and then not making any suggestions on code modification) rather than blindly doing wrong things.
2. The helpful suggestions by haskell-mode are well-meant, but rather disruptive when they are just garbage, which seems to happen in different scenarios (cf. #1834).

Note: there is a previous instance of this issue that the author closed, but there is no evidence it was fixed:
- #1535

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.