-
-
Notifications
You must be signed in to change notification settings - Fork 388
Code action to remove redundant imports is sometimes not created #4220
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Labels
Hackathon
This issue is suitable for hackathon sessions
level: easy
The issue is suited for beginners
type: bug
Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Comments
Hint for anyone looking into fixing this
This seems to happen when the unused field is a record field selector (for both data and newtypes).
When these are unused, GHC warning actually mentions `RecordConstructor(recordFieldName)` in the diagnostic.
The place where this breaks down is in this function: haskell-language-server/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs Lines 1942 to 1955 in 23005f8
which gets passed b::String like RecordConstructor(recordFieldName) , tries to compare it with printOutputable b' which at this point is just recordFieldName , which are not equal and so no code action is generated for these.
|
Looking into this |
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Labels
Hackathon
This issue is suitable for hackathon sessions
level: easy
The issue is suited for beginners
type: bug
Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Using hls 2.7.0.0 in vscode with ghc 9.4.8, I sometimes don't get "remove redundant imports" code action.
Here's a one-module reproducer (assuming you have a cabal project with postgresql-simple dependency):
Although warning is generated and displayed on hover:
The usual code action to remove unused import is not created.
Not a big deal, but it's breaking my flow, as now I have to focus on what the warning is exactly saying and fix it manually 😄
The text was updated successfully, but these errors were encountered: