Skip to content

Suggesting "Hiding other imports"-like action when ambiguity includes local definition #2114

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
Ailrun opened this issue Aug 20, 2021 · 2 comments · Fixed by #2320
Closed
Labels

Comments

@Ailrun
Copy link
Member

Ailrun commented Aug 20, 2021

Your environment

Output of haskell-language-server --probe-tools or haskell-language-server-wrapper --probe-tools:

haskell-language-server version: 1.3.0.0 (GHC: 9.0.1) (PATH: $PATH/haskell-language-server) (GIT hash: 2857eeece0398e1cd4b2ffb6069b05c4d2308b39)
Tool versions found on the $PATH
cabal:          3.4.0.0
stack:          2.7.1
ghc:            8.10.5

Which OS do you use: Manjaro

Which lsp-client do you use: Emacs

Describe your project (alternative: link to the project):

Contents of hie.yaml: Implicit

Steps to reproduce

With this file,

module Test where

useLex :: String
useLex = lex "" -- 'lex' can be either the local definition or 'Prelude.lex'.

lex :: String -> String
lex = id

HLS does not give "Use local, hiding imports" or similar, and just shows "Replace with qualified: Prelude.lex". This works well when ambiguity is caused by two imported definitions.

Expected behaviour

Described as above.

Actual behaviour

Described as above.

Related information

suggestImportDisambiguation ::
DynFlags ->
Maybe T.Text ->
ParsedSource ->
Diagnostic ->
[(T.Text, [Either TextEdit Rewrite])]
suggestImportDisambiguation df (Just txt) ps@(L _ HsModule {hsmodImports}) diag@Diagnostic {..}
| Just [ambiguous] <-
matchRegexUnifySpaces
_message
"Ambiguous occurrence ‘([^’]+)’"
, Just modules <-
map last
<$> allMatchRegexUnifySpaces _message "imported from ‘([^’]+)’" =
suggestions ambiguous modules

checks only "imported from ...", whereas the actual error message with local definition is "defined at ...".

@yoshitsugu
Copy link
Contributor

hi. i'm new here. i'll try to fix this if no one else is already working on.

@jneira
Copy link
Member

jneira commented Nov 1, 2021

@yoshitsugu welcome and many, many thanks to work on this nice feature, looking forward to your pr

@jneira jneira linked a pull request Nov 3, 2021 that will close this issue
@mergify mergify bot closed this as completed in #2320 Nov 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants