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

"Add to import list" fails to add constructor import to type import when they're named the same. #1768

Closed
zmrocze opened this issue Apr 23, 2021 · 1 comment · Fixed by #1775
Labels
component: ghcide type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@zmrocze
Copy link

zmrocze commented Apr 23, 2021

Steps to reproduce

Minimum working example:

module A where
newtype Foo = Foo Int
module B where
import A (Foo)
f :: Foo
f = Foo 1

Expected behaviour

Data constructor Foo in f = Foo 1 is correctly underlined with red as 'Foo' constructor is not in scope. Clicking ctrl+. opens code actions tab. I would expect to find there action "Add Foo(Foo) to the import list of A." that would append to type import also constructor import.

Actual behaviour

Only available code action is "Add Foo to the import list of A.". This action doesn't change the import.
If the constructor name is different from the type name the code action shows properly and works as expected (that is action "Add Foo(MakeFoo) to the import list of A" shows up and works).
The problem also exist if we use data instead of newtype.

Include debug information

LSP logs:

Logs when I click ctrl+. showing code actions tab/menu.

2021-04-23 17:55:10.6277188 [ThreadId 2176] INFO hls:	finish: Pragmas.GetParsedModule (took 0.00s)
2021-04-23 17:55:10.6282292 [ThreadId 2180] INFO hls:	finish: importLens (took 0.00s)
2021-04-23 17:55:10.6282205 [ThreadId 2178] INFO hls:	finish: HaddockComments.GetAnnotatedParsedSource (took 0.00s)
2021-04-23 17:55:10.6284327 [ThreadId 2182] INFO hls:	finish: tactic (took 0.00s)
2021-04-23 17:55:10.6285299 [ThreadId 2183] INFO hls:	finish: splice.codeAction.GitHieAst (took 0.00s)
2021-04-23 17:55:10.6286178 [ThreadId 2184] INFO hls:	finish: CodeAction (took 0.00s)
2021-04-23 17:55:10.6286843 [ThreadId 2186] INFO hls:	finish: retrie (took 0.00s)
2021-04-23 17:55:10.6290103 [ThreadId 2188] INFO hls:	finish: tactic (took 0.00s)
2021-04-23 17:55:10.6291867 [ThreadId 2190] INFO hls:	finish: tactic (took 0.00s)
2021-04-23 17:55:10.629348 [ThreadId 2192] INFO hls:	finish: tactic (took 0.00s)

And then choose option Add "Foo" to the import list of A.

2021-04-23 17:55:32.0173757 [ThreadId 2208] INFO hls:	finish: importLens (took 0.00s)
2021-04-23 17:55:32.017329 [ThreadId 2207] INFO hls:	finish: HaddockComments.GetAnnotatedParsedSource (took 0.00s)
2021-04-23 17:55:32.0174298 [ThreadId 2209] INFO hls:	finish: Pragmas.GetParsedModule (took 0.00s)
2021-04-23 17:55:32.0174404 [ThreadId 2210] INFO hls:	finish: splice.codeAction.GitHieAst (took 0.00s)
2021-04-23 17:55:32.0175202 [ThreadId 2208] INFO hls:	finish: tactic (took 0.00s)
2021-04-23 17:55:32.0175677 [ThreadId 2209] INFO hls:	finish: retrie (took 0.00s)
2021-04-23 17:55:32.0178464 [ThreadId 2211] INFO hls:	finish: tactic (took 0.00s)
2021-04-23 17:55:32.0178972 [ThreadId 2213] INFO hls:	finish: tactic (took 0.00s)
2021-04-23 17:55:32.0179331 [ThreadId 2210] INFO hls:	finish: CodeAction (took 0.00s)
2021-04-23 17:55:32.0180024 [ThreadId 2214] INFO hls:	finish: tactic (took 0.00s)

Your environment

I am sorry but I can't find haskell-language-server executable to tell its version. It's not in the path; not in $HOME in .vscode-server, .cabal, .stack, .local; not on Windows in %APPDATA%\Code\User\globalStorage.
I can only say that I expect it to be recent as VSCode updated hls around a week or two ago.

Which OS do you use:
Windows Subsystem for Linux with Ubuntu 20.04.
Which lsp-client do you use:
VS Code
Describe your project (alternative: link to the project):
stack project

@Ailrun Ailrun added type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. component: ghcide status: needs repro labels Apr 23, 2021
@Ailrun
Copy link
Member

Ailrun commented Apr 24, 2021

Confirmed with Linux/Emacs/no build tool too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: ghcide type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
2 participants