You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
and ModuleA which has an unused record field import within a multi-line import statement:
moduleModuleAwhereimportModuleB
( B (b1),
x,
)
x' = x
Expected behaviour
I expect the code action for removing the unused record field: Remove B, B(b1) from import to be shown on selecting the single line with the unused import.
Actual behaviour
Instead, the code action does not show:
However, it shows when collecting the complete range of the import statement.
The text was updated successfully, but these errors were encountered:
Thanks for the report. I managed to reproduce it using the following single file reproducer:
importData.Monoid
( Sum(getSum)
, getAp
)
x = getAp
The great first step would be to add a failing test case to the test suite which would make it easy to isolate the root cause by rerunning the reproducer and adding Debug.Trace statements in various places.
I'll probably get to fixing this in the next few days but feel free to take a stab at it.
It looks like the range for the warning comes from GHC, so it is probably more a GHC issue than HLS:
src/ModuleA.hs:3:1: warning: [-Wunused-imports]
The import of ‘Sum, Sum(getSum)’
from module ‘Data.Monoid’ is redundant
|
3 | import Data.Monoid
| ^^^^^^^^^^^^^^^^^^...
I'm not sure if that's the issue.
My theory: It might be some logic in HLS which does something like "try to calculate the range of this code action" - which because it fails to identify the correct range due to diagnostic message containing Sum(getSum) vs us looking for range of just getSum which is not found on its own in the AST, so it falls back to code range of the whole import declaration. Then since you have both the
"diagnostic showing the warning" and also
"code action to remove the import"
shown at the same range, you won't see the code action or something like this.
Steps to reproduce
Given
ModuleB
:and
ModuleA
which has an unused record field import within a multi-line import statement:Expected behaviour
I expect the code action for removing the unused record field:
Remove B, B(b1) from import
to be shown on selecting the single line with the unused import.Actual behaviour
Instead, the code action does not show:
However, it shows when collecting the complete range of the import statement.
The text was updated successfully, but these errors were encountered: