haskell / haskell-mode

Emacs mode for Haskell
http://haskell.github.io/haskell-mode/
GNU General Public License v3.0
1.33k stars 344 forks source link

Loading a file under test-suite fails when importing library #1837

Open andreasabel opened 10 months ago

andreasabel commented 10 months ago

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,

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: