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 the import list of ..." Code Action ignores MagicHashed identifiers #660

Closed
konn opened this issue Dec 9, 2020 · 2 comments
Closed
Labels
component: imports plugin type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@konn
Copy link
Collaborator

konn commented Dec 9, 2020

Code Action Add ... to the import list of ... won't appear, if the missing symbol is suffixed with # with MagicHash extension enabled.

Your environment

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

$ ~/Library/Application\ Support/Code/User/globalStorage/haskell.haskell/haskell-language-server-wrapper-0.6.0-darwin 
Found "/Users/hiromi/Documents/Programming/Haskell/git/iapplicative-builder/hie.yaml" for "/Users/hiromi/Documents/Programming/Haskell/git/iapplicative-builder/a"
Module "/Users/hiromi/Documents/Programming/Haskell/git/iapplicative-builder/a" is loaded by Cradle: Cradle {cradleRootDir = "/Users/hiromi/Documents/Programming/Haskell/git/iapplicative-builder", cradleOptsProg = CradleAction: Stack}
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper-0.6.0-darwin) Version 0.6.0.0, Git revision 372a12e797069dc3ac4fa33dcaabe3b992999d7c (dirty) x86_64 ghc-8.10.1
Current directory: /Users/hiromi/Documents/Programming/Haskell/git/iapplicative-builder
Operating system: darwin
Arguments: []
Cradle directory: /Users/hiromi/Documents/Programming/Haskell/git/iapplicative-builder
Cradle type: Stack

Tool versions found on the $PATH
cabal:          3.2.0.0
stack:          2.5.1
ghc:            8.6.5


Consulting the cradle to get project GHC version...
Project GHC version: 8.8.4
haskell-language-server exe candidates: ["haskell-language-server-8.8.4","haskell-language-server-8.8","haskell-language-server"]

Which lsp-client do you use: VSCode

Describe your project (alternative: link to the project): irrelevant to the particular project structure

Contents of hie.yaml: a single file suffices and no cradle file needed.

Steps to reproduce

  1. Save the following as Main.hs (or whatever):

    {-# LANGUAGE MagicHash #-}
    module Main where
    import GHC.Exts (Proxy#)
    
    theVal :: Proxy# Int
    theVal = proxy#
  2. HLS (correctly) highlights proxy#, which is undefined symbol so far.

  3. Open the code actions for proxy#.

Expected behaviour

HLS should suggest Add proxy# to the import list of GHC.Exts

Actual behaviour

Even though HLS detects definition site of proxy# correctly, it lacks Add to the import list!
スクリーンショット 2020-12-09 20 25 20

Include debug information

Execute in the root of your project the command haskell-language-server --debug . and paste the logs here:

Debug output:
$ ~/Library/Application\ Support/Code/User/globalStorage/haskell.haskell/haskell-language-server-0.6.0-darwin-8.6.5 --debug tmp.hs  
haskell-language-server version: 0.6.0.0 (GHC: 8.6.5) (PATH: /Users/hiromi/Library/Application Support/Code/User/globalStorage/haskell.haskell/haskell-language-server-0.6.0-darwin-8.6.5) (GIT hash: 372a12e797069dc3ac4fa33dcaabe3b992999d7c)
(haskell-language-server)Ghcide setup tester in /Users/hiromi.
Report bugs at https://github.com/haskell/haskell-language-server/issues

Tool versions found on the $PATH
cabal:          3.2.0.0
stack:          2.5.1
ghc:            8.6.5


Step 1/4: Finding files to test in /Users/hiromi
Found 1 files

Step 2/4: Looking for hie.yaml files that control setup
Found 1 cradle

Step 3/4: Initializing the IDE

Step 4/4: Type checking the files
[INFO] Consulting the cradle for "tmp.hs"
NotShowMessage (NotificationMessage {_jsonrpc = "2.0", _method = WindowShowMessage, _params = ShowMessageParams {_xtype = MtInfo, _message = "No [cradle](https://github.com/mpickering/hie-bios#hie-bios) found for tmp.hs.\n Proceeding with [implicit cradle](https://hackage.haskell.org/package/implicit-hie).\nYou should ignore this message, unless you see a 'Multi Cradle: No prefixes matched' error."}})
Output from setting up the cradle Cradle {cradleRootDir = "/Users/hiromi", cradleOptsProg = CradleAction: Default}
[INFO] Using interface files cache dir: /Users/hiromi/.cache/ghcide/main-da39a3ee5e6b4b0d3255bfef95601890afd80709
[INFO] Making new HscEnv[main]
File:     /Users/hiromi/tmp.hs
Hidden:   no
Range:    8:10-8:16
Source:   typecheck
Severity: DsError
Message: 
  • Variable not in scope: proxy# :: Proxy# Int
  • Perhaps you want to add ‘proxy#’ to the import list
  in the import of ‘GHC.Exts’ (/Users/hiromi/tmp.hs:5:1-24).

Completed (1 file worked, 0 files failed)

Paste the logs from the lsp-client, e.g. for VS Code

LSP logs:
[client] run command: "/Users/hiromi/Library/Application Support/Code/User/globalStorage/haskell.haskell/haskell-language-server-0.6.0-darwin-8.6.5 --lsp"
[client] debug command: "/Users/hiromi/Library/Application Support/Code/User/globalStorage/haskell.haskell/haskell-language-server-0.6.0-darwin-8.6.5 --lsp"
[client] server cwd: /Users/hiromi
haskell-language-server version: 0.6.0.0 (GHC: 8.6.5) (PATH: /Users/hiromi/Library/Application Support/Code/User/globalStorage/haskell.haskell/haskell-language-server-0.6.0-darwin-8.6.5) (GIT hash: 372a12e797069dc3ac4fa33dcaabe3b992999d7c)
Starting (haskell-language-server)LSP server...
  with arguments: LspArguments {argLSP = True, argsCwd = Nothing, argFiles = [], argsShakeProfiling = Nothing, argsTesting = False, argsExamplePlugin = False, argsDebugOn = False, argsLogFile = Nothing, argsThreads = 0, argsProjectGhcVersion = False}
  with plugins: [PluginId "brittany",PluginId "eval",PluginId "floskell",PluginId "fourmolu",PluginId "ghcide",PluginId "hlint",PluginId "importLens",PluginId "moduleName",PluginId "ormolu",PluginId "pragmas",PluginId "retrie",PluginId "stylish-haskell",PluginId "tactic"]
  in directory: /Users/hiromi
If you are seeing this in a terminal, you probably should have run ghcide WITHOUT the --lsp option!
 Started LSP server in 0.00s
2020-12-09 20:28:09.60771 [ThreadId 25] - Registering ide configuration: IdeConfiguration {workspaceFolders = fromList [], clientSettings = hashed Nothing}
2020-12-09 20:28:09.609568 [ThreadId 25] - Configuration changed: Object (fromList [("haskell",Object (fromList [("hlint",Object (fromList [("logLevel",String "info"),("executablePath",String "/Users/hiromi/.local/bin/hlint")])),("logFile",String ""),("updateBehavior",String "keep-up-to-date"),("hlintOn",Bool True),("formatOnImportOn",Bool True),("indentationRules",Object (fromList [("enabled",Bool True)])),("liquidOn",Bool False),("languageServerVariant",String "haskell-language-server"),("serverExecutablePath",String ""),("diagnosticsOnChange",Bool True),("completionSnippetsOn",Bool True),("maxNumberOfProblems",Number 100.0),("formattingProvider",String "fourmolu"),("trace",Object (fromList [("server",String "off")]))]))])
2020-12-09 20:28:09.610792 [ThreadId 25] - Opened text document: file:///Users/hiromi/tmp.hs
2020-12-09 20:28:09.612351 [ThreadId 115] - getClientConfigAction:clientSettings:Just (Object (fromList [("haskell",Object (fromList [("hlint",Object (fromList [("logLevel",String "info"),("executablePath",String "/Users/hiromi/.local/bin/hlint")])),("logFile",String ""),("updateBehavior",String "keep-up-to-date"),("hlintOn",Bool True),("formatOnImportOn",Bool True),("indentationRules",Object (fromList [("enabled",Bool True)])),("liquidOn",Bool False),("languageServerVariant",String "haskell-language-server"),("serverExecutablePath",String ""),("diagnosticsOnChange",Bool True),("completionSnippetsOn",Bool True),("maxNumberOfProblems",Number 100.0),("formattingProvider",String "fourmolu"),("trace",Object (fromList [("server",String "off")]))]))]))
2020-12-09 20:28:09.612596 [ThreadId 115] - hlint:getIdeas:file:NormalizedFilePath "/Users/hiromi/tmp.hs"
2020-12-09 20:28:09.613512 [ThreadId 122] - Consulting the cradle for "tmp.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/Users/hiromi", cradleOptsProg = CradleAction: Default}
2020-12-09 20:28:09.816025 [ThreadId 122] - Using interface files cache dir: /Users/hiromi/.cache/ghcide/main-da39a3ee5e6b4b0d3255bfef95601890afd80709
2020-12-09 20:28:09.816178 [ThreadId 122] - Making new HscEnv[main]
2020-12-09 20:28:09.830523 [ThreadId 185] - getClientConfigAction:clientSettings:Just (Object (fromList [("haskell",Object (fromList [("hlint",Object (fromList [("logLevel",String "info"),("executablePath",String "/Users/hiromi/.local/bin/hlint")])),("logFile",String ""),("updateBehavior",String "keep-up-to-date"),("hlintOn",Bool True),("formatOnImportOn",Bool True),("indentationRules",Object (fromList [("enabled",Bool True)])),("liquidOn",Bool False),("languageServerVariant",String "haskell-language-server"),("serverExecutablePath",String ""),("diagnosticsOnChange",Bool True),("completionSnippetsOn",Bool True),("maxNumberOfProblems",Number 100.0),("formattingProvider",String "fourmolu"),("trace",Object (fromList [("server",String "off")]))]))]))
2020-12-09 20:28:09.83073 [ThreadId 185] - hlint:getIdeas:file:NormalizedFilePath "/Users/hiromi/tmp.hs"
2020-12-09 20:28:09.86826 [ThreadId 251] - Plugin.makeCodeLens (ideLogger)
2020-12-09 20:28:09.868595 [ThreadId 253] - finish: codeLens (took 0.00s)
2020-12-09 20:28:09.869147 [ThreadId 258] - finish:  (took 0.00s)
2020-12-09 20:28:09.869455 [ThreadId 259] - finish: ModuleName.ghcSession (took 0.00s)
2020-12-09 20:28:09.869755 [ThreadId 261] - finish: ModuleName.GetParsedModule (took 0.00s)
2020-12-09 20:28:10.103483 [ThreadId 265] - hlint:getIdeas:setExtensions:[Cpp,OverlappingInstances,UndecidableInstances,IncoherentInstances,UndecidableSuperClasses,MonomorphismRestriction,MonoPatBinds,MonoLocalBinds,RelaxedPolyRec,ExtendedDefaultRules,ForeignFunctionInterface,UnliftedFFITypes,InterruptibleFFI,CApiFFI,GHCForeignImportPrim,JavaScriptFFI,ParallelArrays,TemplateHaskell,TemplateHaskellQuotes,ImplicitParams,ImplicitPrelude,ScopedTypeVariables,AllowAmbiguousTypes,UnliftedNewtypes,BangPatterns,TypeFamilies,TypeFamilyDependencies,TypeInType,OverloadedStrings,OverloadedLists,NumDecimals,DisambiguateRecordFields,RecordWildCards,RecordPuns,ViewPatterns,GADTs,GADTSyntax,NPlusKPatterns,DoAndIfThenElse,BlockArguments,RebindableSyntax,ConstraintKinds,PolyKinds,DataKinds,InstanceSigs,ApplicativeDo,StandaloneDeriving,DeriveDataTypeable,AutoDeriveTypeable,DeriveFunctor,DeriveTraversable,DeriveFoldable,DeriveGeneric,DefaultSignatures,DeriveAnyClass,DeriveLift,DerivingStrategies,DerivingVia,TypeSynonymInstances,FlexibleContexts,FlexibleInstances,ConstrainedClassMethods,MultiParamTypeClasses,NullaryTypeClasses,FunctionalDependencies,UnicodeSyntax,ExistentialQuantification,MagicHash,EmptyDataDecls,KindSignatures,RoleAnnotations,ParallelListComp,MonadComprehensions,GeneralizedNewtypeDeriving,PostfixOperators,TupleSections,PatternGuards,LiberalTypeSynonyms,RankNTypes,ImpredicativeTypes,TypeOperators,ExplicitNamespaces,PackageImports,ExplicitForAll,AlternativeLayoutRuleTransitional,DatatypeContexts,NondecreasingIndentation,RelaxedLayout,TraditionalRecordSyntax,LambdaCase,MultiWayIf,BinaryLiterals,HexFloatLiterals,DuplicateRecordFields,OverloadedLabels,EmptyCase,PatternSynonyms,PartialTypeSignatures,NamedWildCards,TypeApplications,Strict,StrictData,MonadFailDesugaring,EmptyDataDeriving,NumericUnderscores,QuantifiedConstraints,ImportQualifiedPost,CUSKs,StandaloneKindSignatures,StarIsType]
2020-12-09 20:28:10.581973 [ThreadId 269] - DocumentHighlight request at position 8:13 in file: /Users/hiromi/tmp.hs
2020-12-09 20:28:10.856607 [ThreadId 276] - finish: CodeAction (took 0.00s)
2020-12-09 20:28:12.220597 [ThreadId 285] - finish: CodeAction (took 0.00s)
2020-12-09 20:28:12.980925 [ThreadId 291] - finish: CodeAction:PackageExports (took 2.12s)
@berberman
Copy link
Collaborator

I think haskell/ghcide#916 also fixed this. Wait for the release :)
image

@jneira jneira added component: imports plugin type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. labels Dec 9, 2020
@konn
Copy link
Collaborator Author

konn commented Dec 10, 2020

Great, thanks!

@konn konn closed this as completed Dec 10, 2020
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

No branches or pull requests

3 participants