Skip to content

Add ctor to import list code action broken with ghc 9.2 #2662

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

Closed
guibou opened this issue Jan 31, 2022 · 3 comments · Fixed by #2697
Closed

Add ctor to import list code action broken with ghc 9.2 #2662

guibou opened this issue Jan 31, 2022 · 3 comments · Fixed by #2697
Labels
component: imports plugin type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@guibou
Copy link
Collaborator

guibou commented Jan 31, 2022

Add to import list code action is broken with GHC 9.2, because it does not includes comma between symbols:

HLSAddImportMissingComa

Your environment

Which OS do you use: Linux
Which LSP client (editor/plugin) do you use: Neovim + lsp_config
Describe your project (alternative: link to the project): standalone file

Steps to reproduce

Test with the following file:

import Data.List.NonEmpty (fromList)

a = case fromList [1,2,3] of
      a :| l -> "boo"

Error should complain about :| not being in scope, and a code action should propose to add :| to the import list of Data.List.NonEmpty. You can execute the code action.

Expected behaviour

Code action should change the import list to something valid, such as (fromList, NonEmpty((:|))).

Actual behaviour

Executing the code action changes the import list from (fromList) to (fromListNonEmpty((:|)) effectively missing the comma, generating a parse error.

Include debug information

@guibou guibou added status: needs triage type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. labels Jan 31, 2022
@guibou
Copy link
Collaborator Author

guibou commented Jan 31, 2022

I can reproduce in a unit test. I'll push an MR soon with the test.

@jneira
Copy link
Member

jneira commented Jan 31, 2022

thanks for the bug report, I am a little bit surprised it has not been catch by an existing functional test

guibou added a commit to guibou/haskell-language-server that referenced this issue Jan 31, 2022
@guibou guibou changed the title Add to import list code action broken with ghc 9.2 Add ctor to import list code action broken with ghc 9.2 Jan 31, 2022
@guibou
Copy link
Collaborator Author

guibou commented Jan 31, 2022

Repro pushed. Looks like the problem only happen for constructors. The test includes test for infix constructors, but it also fails for prefix constructors. edit: added test for prefix ctors.

guibou added a commit to guibou/haskell-language-server that referenced this issue Jan 31, 2022
mergify bot pushed a commit that referenced this issue Jan 31, 2022
* test: repro for #2662: extend import list miss separator

* test: Add test for import list extension with prefix ctor

* test: Mark failing test explicitly with GHC 9.2

They are failing because of #2662.

* test: use knownBrokenForGhcVersions instead of ignoreForGHC92

The first one will fail once the test is fixed.

Co-authored-by: Javier Neira <[email protected]>
guibou added a commit that referenced this issue Feb 8, 2022
The comma annotation was missing.

Close #2662.
guibou added a commit that referenced this issue Feb 8, 2022
The comma annotation was missing.

Close #2662.
@mergify mergify bot closed this as completed in #2697 Feb 9, 2022
mergify bot added a commit that referenced this issue Feb 9, 2022
* fix: handle comma in extend import list with ghc 9.2

The comma annotation was missing.

Close #2662.

* Update ghcide/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs

Co-authored-by: Pepe Iborra <[email protected]>

* refactor: extract addCommaInImportList

Co-authored-by: Pepe Iborra <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: imports plugin type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants