Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
andreasabel opened this issue Jan 16, 2024 · 0 comments
Open

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

andreasabel opened this issue Jan 16, 2024 · 0 comments

Comments

@andreasabel
Copy link
Member

andreasabel commented Jan 16, 2024

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. Add {-# LANGUAGE Data #-} to the top of the file? (y or n)  #1834).

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant