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

"Refine imports" code lens suggests to import internal module in multi-component project #2851

Open
konsumlamm opened this issue Apr 23, 2022 · 2 comments
Labels
component: imports plugin multi-component Issues relating to multi-component support type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@konsumlamm
Copy link

Example

Project structure:

├── hls-issues.cabal
├── src
│   ├── Internal.hs
│   └── Lib.hs
└── test
    └── Test.hs

Internal.hs

module Internal (example) where

example :: Int
example = 5

hls-issues.cabal

cabal-version:      2.4
name:               hls-issues
version:            0.1.0.0

library
    exposed-modules:  Lib
    other-modules:
        Internal
    build-depends:    base ^>= 4.15, containers
    hs-source-dirs:   src
    default-language: Haskell2010

test-suite test
    hs-source-dirs:   test
    main-is:          Test.hs
    type:             exitcode-stdio-1.0
    build-depends:    base ^>= 4.15, hls-issues
    default-language: Haskell2010

Lib.hs

module Lib (example) where

import Internal

Test.hs

import Lib (example)

lol :: Int
lol = example

image

HLS suggests to refine the imports to import Internal, eventhough Internal is not exposed from the library component and thus can't be used in the test suite.

@konsumlamm konsumlamm added status: needs triage type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. labels Apr 23, 2022
@drsooch
Copy link
Collaborator

drsooch commented May 3, 2022

I wasn't able to reproduce for 8.10.7, 9.0.2, and 9.2.2 on HLS 1.7 and 1.6.1.

@drsooch
Copy link
Collaborator

drsooch commented May 3, 2022

I take that back, apparently you have to open one of the src files first.

Curiously, when you refine the import in the Test file, there are no compilation errors generated.

@michaelpj michaelpj added the multi-component Issues relating to multi-component support label Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: imports plugin multi-component Issues relating to multi-component support type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

No branches or pull requests

3 participants