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

HLint fails to parse code that is invalid in disabled extensions #1279

Closed
maksbotan opened this issue Jan 31, 2021 · 6 comments · Fixed by #2671
Closed

HLint fails to parse code that is invalid in disabled extensions #1279

maksbotan opened this issue Jan 31, 2021 · 6 comments · Fixed by #2671
Labels
component: hls-hlint-plugin type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@maksbotan
Copy link
Contributor

maksbotan commented Jan 31, 2021

Your environment

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

$ haskell-language-server-wrapper --probe-tools
haskell-language-server version: 0.9.0.0 (GHC: 8.10.1) (PATH: /Users/maksbotan/.local/bin/haskell-language-server-wrapper) (GIT hash: 46d2a3dc7ef49ba57b2706022af1801149ab3f2b)
Tool versions found on the $PATH
cabal:		3.2.0.0
stack:		2.5.1
ghc:		8.8.4

Which lsp-client do you use:

vim version: NVIM v0.4.4
node version: v14.15.0
coc.nvim version: 0.0.80-50544406f0

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

module Foo (pattern) where

pattern = 42

Steps to reproduce

Open the above module.

Expected behaviour

No errors.

Actual behaviour

[hlint parser] [I] parse error on input `)'
> module Foo (pattern) where
  
  pattern = 42

Include debug information

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

Debug output:
$ haskell-language-server-8.8.4 --debug ptrn.hs
haskell-language-server version: 0.9.0.0 (GHC: 8.8.4) (PATH: /Users/maksbotan/.local/bin/haskell-language-server-8.8.4) (GIT hash: 46d2a3dc7ef49ba57b2706022af1801149ab3f2b)
(haskell-language-server)Ghcide setup tester in /Users/maksbotan/temp.
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.8.4


Step 1/4: Finding files to test in /Users/maksbotan/temp
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 "ptrn.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 ptrn.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/maksbotan/temp", cradleOptsProg = CradleAction: Default}
Loaded package environment from /Users/maksbotan/.ghc/x86_64-darwin-8.8.4/environments/default
[INFO] Using interface files cache dir: ghcide
[INFO] Making new HscEnv[main]

[INFO] finish: User TypeCheck (took 0.02s)
Completed (1 file worked, 0 files failed)

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

LSP logs:
haskell-lsp:Starting up server ...
2021-01-31 14:59:49.327691 [ThreadId 5] - ---> {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":89104,"rootPath":"/Users/maksbotan/temp","rootUri":"file:///Users/maksbotan/temp","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","rename","delete"],"failureHandling":"textOnlyTransactional"},"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"tagSupport":{"valueSet":[1]}},"executeCommand":{"dynamicRegistration":true},"configuration":true,"workspaceFolders":true},"textDocument":{"publishDiagnostics":{"relatedInformation":true,"versionSupport":false,"tagSupport":{"valueSet":[1,2]}},"synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"contextSupport":true,"completionItem":{"snippetSupport":true,"commitCharactersSupport":true,"documentationFormat":["markdown","plaintext"],"deprecatedSupport":true,"preselectSupport":true,"tagSupport":{"valueSet":[1]}},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]}},"hover":{"dynamicRegistration":true,"contentFormat":["markdown","plaintext"]},"signatureHelp":{"dynamicRegistration":true,"contextSupport":true,"signatureInformation":{"documentationFormat":["markdown","plaintext"],"activeParameterSupport":true,"parameterInformation":{"labelOffsetSupport":true}}},"definition":{"dynamicRegistration":true},"references":{"dynamicRegistration":true},"documentHighlight":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"hierarchicalDocumentSymbolSupport":true,"tagSupport":{"valueSet":[1]}},"codeAction":{"dynamicRegistration":true,"isPreferredSupport":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"codeLens":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"prepareSupport":true},"documentLink":{"dynamicRegistration":true,"tooltipSupport":true},"typeDefinition":{"dynamicRegistration":true},"implementation":{"dynamicRegistration":true},"declaration":{"dynamicRegistration":true},"colorProvider":{"dynamicRegistration":true},"foldingRange":{"dynamicRegistration":true,"rangeLimit":5000,"lineFoldingOnly":true},"selectionRange":{"dynamicRegistration":true}},"window":{"workDoneProgress":true}},"initializationOptions":{},"trace":"off","workspaceFolders":[{"uri":"file:///Users/maksbotan/temp","name":"temp"}],"clientInfo":{"name":"coc.nvim","version":"0.0.80"},"workDoneToken":"14fa7786-9eb5-4307-8679-932487a81e4d"}}
2021-01-31 14:59:49.328639 [ThreadId 5] - haskell-lsp:initializeRequestHandler: setting current dir to project root:/Users/maksbotan/temp
2021-01-31 14:59:49.329466 [ThreadId 7] - <--2--{"jsonrpc":"2.0","params":{"type":1,"message":"haskell-lsp:configuration parse error. RequestMessage {_jsonrpc = \"2.0\", _id = IdInt 0, _method = Initialize, _params = InitializeParams {_processId = Just 89104, _rootPath = Just \"/Users/maksbotan/temp\", _rootUri = Just (Uri {getUri = \"file:///Users/maksbotan/temp\"}), _initializationOptions = Just (Object (fromList [])), _capabilities = ClientCapabilities {_workspace = Just (WorkspaceClientCapabilities {_applyEdit = Just True, _workspaceEdit = Just (WorkspaceEditClientCapabilities {_documentChanges = Just True}), _didChangeConfiguration = Just (DidChangeConfigurationClientCapabilities {_dynamicRegistration = Just True}), _didChangeWatchedFiles = Just (DidChangeWatchedFilesClientCapabilities {_dynamicRegistration = Just True}), _symbol = Just (SymbolClientCapabilities {_dynamicRegistration = Just True, _symbolKind = Just (SymbolKindClientCapabilities {_valueSet = Just (List [SkFile,SkModule,SkNamespace,SkPackage,SkClass,SkMethod,SkProperty,SkField,SkConstructor,SkEnum,SkInterface,SkFunction,SkVariable,SkConstant,SkString,SkNumber,SkBoolean,SkArray,SkObject,SkKey,SkNull,SkEnumMember,SkStruct,SkEvent,SkOperator,SkTypeParameter])})}), _executeCommand = Just (ExecuteClientCapabilities {_dynamicRegistration = Just True}), _workspaceFolders = Just True, _configuration = Just True}), _textDocument = Just (TextDocumentClientCapabilities {_synchronization = Just (SynchronizationTextDocumentClientCapabilities {_dynamicRegistration = Just True, _willSave = Just True, _willSaveWaitUntil = Just True, _didSave = Just True}), _completion = Just (CompletionClientCapabilities {_dynamicRegistration = Just True, _completionItem = Just (CompletionItemClientCapabilities {_snippetSupport = Just True, _commitCharactersSupport = Just True, _documentationFormat = Just (List [MkMarkdown,MkPlainText]), _deprecatedSupport = Just True, _preselectSupport = Just True, _tagSupport = Just (CompletionItemTagsClientCapabilities {_valueSet = List [CtDeprecated]})}), _completionItemKind = Just (CompletionItemKindClientCapabilities {_valueSet = Just (List [CiText,CiMethod,CiFunction,CiConstructor,CiField,CiVariable,CiClass,CiInterface,CiModule,CiProperty,CiUnit,CiValue,CiEnum,CiKeyword,CiSnippet,CiColor,CiFile,CiReference,CiFolder,CiEnumMember,CiConstant,CiStruct,CiEvent,CiOperator,CiTypeParameter])}), _contextSupport = Just True}), _hover = Just (HoverClientCapabilities {_dynamicRegistration = Just True, _contentFormat = Just (List [MkMarkdown,MkPlainText])}), _signatureHelp = Just (SignatureHelpClientCapabilities {_dynamicRegistration = Just True, _signatureInformation = Just (SignatureInformationClientCapabilities {documentationFormat = Nothing})}), _references = Just (ReferencesClientCapabilities {_dynamicRegistration = Just True}), _documentHighlight = Just (DocumentHighlightClientCapabilities {_dynamicRegistration = Just True}), _documentSymbol = Just (DocumentSymbolClientCapabilities {_dynamicRegistration = Just True, _symbolKind = Just (DocumentSymbolKindClientCapabilities {_valueSet = Just (List [SkFile,SkModule,SkNamespace,SkPackage,SkClass,SkMethod,SkProperty,SkField,SkConstructor,SkEnum,SkInterface,SkFunction,SkVariable,SkConstant,SkString,SkNumber,SkBoolean,SkArray,SkObject,SkKey,SkNull,SkEnumMember,SkStruct,SkEvent,SkOperator,SkTypeParameter])}), _hierarchicalDocumentSymbolSupport = Just True}), _formatting = Just (FormattingClientCapabilities {_dynamicRegistration = Just True}), _rangeFormatting = Just (RangeFormattingClientCapabilities {_dynamicRegistration = Just True}), _onTypeFormatting = Just (OnTypeFormattingClientCapabilities {_dynamicRegistration = Just True}), _definition = Just (DefinitionClientCapabilities {_dynamicRegistration = Just True}), _typeDefinition = Just (TypeDefinitionClientCapabilities {_dynamicRegistration = Just True}), _implementation = Just (ImplementationClientCapabilities {_dynamicRegistration = Just True}), _codeAction = Just (CodeActionClientCapabilities {_dynamicRegistration = Just True, _codeActionLiteralSupport = Just (CodeActionLiteralSupport {_codeActionKind = CodeActionKindClientCapabilities {_valueSet = List [CodeActionUnknown \"\",CodeActionQuickFix,CodeActionRefactor,CodeActionRefactorExtract,CodeActionRefactorInline,CodeActionRefactorRewrite,CodeActionSource,CodeActionSourceOrganizeImports]}})}), _codeLens = Just (CodeLensClientCapabilities {_dynamicRegistration = Just True}), _documentLink = Just (DocumentLinkClientCapabilities {_dynamicRegistration = Just True}), _colorProvider = Just (ColorProviderClientCapabilities {_dynamicRegistration = Just True}), _rename = Just (RenameClientCapabilities {_dynamicRegistration = Just True, _prepareSupport = Just True}), _publishDiagnostics = Just (PublishDiagnosticsClientCapabilities {_relatedInformation = Just True, _tagSupport = Just (PublishDiagnosticsTagsClientCapabilities {_valueSet = List [DtUnnecessary,DtDeprecated]})}), _foldingRange = Just (FoldingRangeClientCapabilities {_dynamicRegistration = Just True, _rangeLimit = Just 5000, _lineFoldingOnly = Just True})}), _window = Just (WindowClientCapabilities {_workDoneProgress = Just True}), _experimental = Nothing}, _trace = Just TraceOff, _workspaceFolders = Just (List [WorkspaceFolder {_uri = \"file:///Users/maksbotan/temp\", _name = \"temp\"}])}} \"key \\\"languageServerHaskell\\\" not found\""},"method":"window/logMessage"}
2021-01-31 14:59:49.503625 [ThreadId 21] - Registering ide configuration: IdeConfiguration {workspaceFolders = fromList [NormalizedUri (-5617253724344668367) "file:///Users/maksbotan/temp"], clientSettings = hashed (Just (Object (fromList [])))}
2021-01-31 14:59:49.50386 [ThreadId 7] - <--2--{"result":{"capabilities":{"typeDefinitionProvider":true,"foldingRangeProvider":false,"textDocumentSync":{"openClose":true,"change":2,"save":{}},"workspace":{"workspaceFolders":{"supported":true,"changeNotifications":true}},"implementationProvider":true,"documentRangeFormattingProvider":true,"documentHighlightProvider":true,"executeCommandProvider":{"commands":["89114:class:addMinimalMethodPlaceholders","89114:eval:evalCommand","89114:ghcide-type-lenses:typesignature.add","89114:hlint:applyOne","89114:hlint:applyAll","89114:importLens:ImportLensCommand","89114:moduleName:edit","89114:retrie:retrieCommand","89114:splice:expandTHSpliceInplace","89114:tactic:tacticsAutoCommand","89114:tactic:tacticsIntrosCommand","89114:tactic:tacticsDestructCommand","89114:tactic:tacticsHomomorphismCommand","89114:tactic:tacticsDestructLambdaCaseCommand","89114:tactic:tacticsHomomorphismLambdaCaseCommand"]},"renameProvider":false,"colorProvider":false,"definitionProvider":true,"hoverProvider":true,"codeActionProvider":true,"completionProvider":{"triggerCharacters":["."],"resolveProvider":false},"codeLensProvider":{},"documentSymbolProvider":true,"documentFormattingProvider":true}},"jsonrpc":"2.0","id":0}
2021-01-31 14:59:49.50522 [ThreadId 5] - ---> {"jsonrpc":"2.0","method":"initialized","params":{}}
2021-01-31 14:59:49.505517 [ThreadId 7] - <--2--{"jsonrpc":"2.0","params":{"registrations":[{"registerOptions":{"watchers":[{"kind":5,"globPattern":"**/*.hs"},{"kind":5,"globPattern":"**/*.hs-boot"},{"kind":5,"globPattern":"**/*.lhs"},{"kind":5,"globPattern":"**/*.lhs-boot"}]},"method":"workspace/didChangeWatchedFiles","id":"globalFileWatches"}]},"method":"client/registerCapability","id":0}
2021-01-31 14:59:49.505886 [ThreadId 5] - ---> {"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"haskell":{"formattingProvider":"stylish-haskell","completionSnippetsOn":false}}}}
2021-01-31 14:59:49.50604 [ThreadId 21] - Configuration changed: Object (fromList [("haskell",Object (fromList [("completionSnippetsOn",Bool False),("formattingProvider",String "stylish-haskell")]))])
2021-01-31 14:59:49.506209 [ThreadId 20] - Finishing build session(exception: AsyncCancelled)
2021-01-31 14:59:49.50627 [ThreadId 21] - Restarting build session (aborting the previous one took 0.00s)
2021-01-31 14:59:49.506372 [ThreadId 5] - ---> {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///Users/maksbotan/temp/ptrn.hs","languageId":"haskell","version":1,"text":"module Foo (pattern) where\n\npattern = 42\n"}}}
2021-01-31 14:59:49.506591 [ThreadId 21] - Set files of interest to: [(NormalizedFilePath "/Users/maksbotan/temp/ptrn.hs",Modified)]
2021-01-31 14:59:49.506767 [ThreadId 21] - Restarting build session (aborting the previous one took 0.00s)
2021-01-31 14:59:49.506746 [ThreadId 40] - Finishing build session(exception: AsyncCancelled)
2021-01-31 14:59:49.506875 [ThreadId 21] - Opened text document: file:///Users/maksbotan/temp/ptrn.hs
2021-01-31 14:59:49.507473 [ThreadId 91] - hlint:getIdeas:file:NormalizedFilePath "/Users/maksbotan/temp/ptrn.hs"
2021-01-31 14:59:49.508655 [ThreadId 97] - Consulting the cradle for "ptrn.hs"
2021-01-31 14:59:49.508864 [ThreadId 7] - <--2--{"jsonrpc":"2.0","params":{"type":3,"message":"No [cradle](https://github.com/mpickering/hie-bios#hie-bios) found for ptrn.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."},"method":"window/showMessage"}
2021-01-31 14:59:49.513688 [ThreadId 5] - ---> {"jsonrpc":"2.0","id":0,"result":null}
2021-01-31 14:59:49.513831 [ThreadId 5] - haskell-lsp:Got reply message:"{\"jsonrpc\":\"2.0\",\"id\":0,\"result\":null}"
2021-01-31 14:59:49.526888 [ThreadId 7] - <--2--{"jsonrpc":"2.0","params":{"token":0},"method":"window/workDoneProgress/create","id":1}
2021-01-31 14:59:49.527022 [ThreadId 7] - <--2--{"jsonrpc":"2.0","params":{"value":{"kind":"begin","cancellable":false,"title":"Setting up temp (for ptrn.hs)"},"token":0},"method":"$/progress"}
2021-01-31 14:59:49.527747 [ThreadId 5] - ---> {"jsonrpc":"2.0","id":1,"result":null}
2021-01-31 14:59:49.527877 [ThreadId 5] - haskell-lsp:Got reply message:"{\"jsonrpc\":\"2.0\",\"id\":1,\"result\":null}"
2021-01-31 14:59:49.608357 [ThreadId 97] - Session loading result: Right (ComponentOptions {componentOptions = [], componentRoot = "/Users/maksbotan/temp", componentDependencies = []},"/nix/store/9rirdmvjbxiic7g38jhx7gmr15nnj5z7-ghc-8.8.4/lib/ghc-8.8.4")
2021-01-31 14:59:49.608423 [ThreadId 7] - <--2--{"jsonrpc":"2.0","params":{"value":{"kind":"end"},"token":0},"method":"$/progress"}
2021-01-31 14:59:49.611717 [ThreadId 7] - <--2--{"jsonrpc":"2.0","params":{"token":"24"},"method":"window/workDoneProgress/create","id":2}
2021-01-31 14:59:49.611842 [ThreadId 7] - <--2--{"jsonrpc":"2.0","params":{"value":{"kind":"begin","title":"Processing"},"token":"24"},"method":"$/progress"}
2021-01-31 14:59:49.612351 [ThreadId 5] - ---> {"jsonrpc":"2.0","id":2,"result":null}
2021-01-31 14:59:49.612428 [ThreadId 5] - haskell-lsp:Got reply message:"{\"jsonrpc\":\"2.0\",\"id\":2,\"result\":null}"
2021-01-31 14:59:49.673494 [ThreadId 97] - Using interface files cache dir: ghcide
2021-01-31 14:59:49.673588 [ThreadId 97] - Making new HscEnv[main]
2021-01-31 14:59:49.682998 [ThreadId 97] - New Component Cache HscEnvEq: (([],Just HscEnvEq 25),fromList [])
2021-01-31 14:59:49.683147 [ThreadId 97] - Known files updated: fromList [(TargetFile NormalizedFilePath "/Users/maksbotan/temp/ptrn.hs",["/Users/maksbotan/temp/ptrn.hs"])]
2021-01-31 14:59:49.683398 [ThreadId 97] - Restarting build session (aborting the previous one took 0.00s)
2021-01-31 14:59:49.68355 [ThreadId 62] - Finishing build session(exception: AsyncCancelled)
2021-01-31 14:59:49.684888 [ThreadId 148] - hlint:getIdeas:file:NormalizedFilePath "/Users/maksbotan/temp/ptrn.hs"
2021-01-31 14:59:49.686447 [ThreadId 177] - 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]
2021-01-31 14:59:49.687662 [ThreadId 7] - <--2--{"jsonrpc":"2.0","params":{"uri":"file:///Users/maksbotan/temp/ptrn.hs","diagnostics":[{"severity":3,"range":{"start":{"line":0,"character":19},"end":{"line":0,"character":20}},"code":"parser","source":"hlint","message":"parse error on input `)'\n> module Foo (pattern) where\n  \n  pattern = 42\n\n"}]},"method":"textDocument/publishDiagnostics"}
2021-01-31 14:59:49.710085 [ThreadId 7] - <--2--{"jsonrpc":"2.0","params":{"value":{"kind":"end"},"token":"24"},"method":"$/progress"}
2021-01-31 14:59:49.710318 [ThreadId 211] - finish: InitialLoad (took 0.03s)
2021-01-31 14:59:52.752043 [ThreadId 5] - ---> {"jsonrpc":"2.0","id":1,"method":"textDocument/codeLens","params":{"textDocument":{"uri":"file:///Users/maksbotan/temp/ptrn.hs"}}}
2021-01-31 14:59:52.752483 [ThreadId 214] - Plugin.makeCodeLens (ideLogger)
2021-01-31 14:59:52.752867 [ThreadId 215] - src/Ide/Plugin/Eval/CodeLens.hs:239:15 "fp" "/Users/maksbotan/temp/ptrn.hs"
2021-01-31 14:59:52.753114 [ThreadId 223] - finish: codeLens (took 0.00s)
2021-01-31 14:59:52.753623 [ThreadId 225] - finish: ModuleName.GetParsedModule (took 0.00s)
2021-01-31 14:59:52.753705 [ThreadId 230] - finish: getSession (took 0.00s)
2021-01-31 14:59:52.753881 [ThreadId 232] - finish:  (took 0.00s)
2021-01-31 14:59:52.753949 [ThreadId 215] - src/Ide/Plugin/Eval/CodeLens.hs:239:15 "preprocessor" "0.00s"
2021-01-31 14:59:52.754222 [ThreadId 215] - src/Ide/Plugin/Eval/CodeLens.hs:239:15 "Tests" "0 tests in 0 sections 0 setups 0 lenses."
2021-01-31 14:59:52.754462 [ThreadId 215] - src/Ide/Plugin/Eval/CodeLens.hs:239:15 "tests" "0.00s"
2021-01-31 14:59:52.754603 [ThreadId 215] - src/Ide/Plugin/Eval/CodeLens.hs:239:15 "codeLens" "0.00s"
2021-01-31 14:59:52.755225 [ThreadId 7] - <--2--{"result":[{"command":{"command":"89114:ghcide-type-lenses:typesignature.add","arguments":[{"changes":{"file:///Users/maksbotan/temp/ptrn.hs":[{"range":{"start":{"line":2,"character":0},"end":{"line":2,"character":0}},"newText":"pattern :: Integer\n"}]}}],"title":"pattern :: Integer"},"range":{"start":{"line":2,"character":0},"end":{"line":2,"character":7}}},{"command":{"command":"89114:moduleName:edit","arguments":["file:///Users/maksbotan/temp/ptrn.hs"],"title":"Set module name to Main"},"range":{"start":{"line":0,"character":7},"end":{"line":0,"character":10}}}],"jsonrpc":"2.0","id":1}
2021-01-31 14:59:52.75782 [ThreadId 5] - ---> {"jsonrpc":"2.0","id":2,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///Users/maksbotan/temp/ptrn.hs"},"position":{"line":0,"character":0}}}
2021-01-31 14:59:52.758247 [ThreadId 236] - DocumentHighlight request at position 1:1 in file: /Users/maksbotan/temp/ptrn.hs
2021-01-31 14:59:52.758606 [ThreadId 237] - finish: C:GetHieAst (took 0.00s)
2021-01-31 14:59:52.758715 [ThreadId 7] - <--2--{"result":[],"jsonrpc":"2.0","id":2}
2021-01-31 14:59:53.31644 [ThreadId 5] - ---> {"jsonrpc":"2.0","method":"textDocument/didClose","params":{"textDocument":{"uri":"file:///Users/maksbotan/temp/ptrn.hs"}}}
2021-01-31 14:59:53.316814 [ThreadId 5] - Closed: Uri {getUri = "file:///Users/maksbotan/temp/ptrn.hs"}
2021-01-31 14:59:53.317118 [ThreadId 21] - Set files of interest to: []
2021-01-31 14:59:53.317316 [ThreadId 21] - Closed text document: file:///Users/maksbotan/temp/ptrn.hs
2021-01-31 14:59:53.317567 [ThreadId 240] - Typechecking reverse dependencies for NormalizedFilePath "/Users/maksbotan/temp/ptrn.hs": Just []
2021-01-31 14:59:53.317712 [ThreadId 240] - finish: ParentTC (took 0.00s)

As you can see, HLS enables all extensions for HLint, including PatternSynonyms, which makes pattern a reserved keyword. I, however, do not enable it in my Haskell source and am free to use it as I like. Therefore HLint is broken for this file.

@jneira
Copy link
Member

jneira commented Jan 31, 2021

@maksbotan yeah, hlint enables by default a bunch of extensions known to be relatively innocuous, but in this (somewhat corner?) case it cant parse the module.
I guess if you uses hlint directly in the cli it behaves in a similar way, or doesnt?

@jneira jneira added component: hls-hlint-plugin status: regression test needed type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. labels Jan 31, 2021
@maksbotan
Copy link
Contributor Author

Yeah, you are right. I've never used HLint on its own, so wasn't aware of this.

$ hlint --version
HLint v3.2.7, (C) Neil Mitchell 2006-2021
$ hlint ptrn.hs 
ptrn.hs:1:20: Error: Parse error: on input `)'
Found:
  > module Foo (pattern) where
    
    pattern = 42
  

1 hint

@maksbotan
Copy link
Contributor Author

Would it make sense to make HLint explicitly enable the same set of extensions as passed to GHC for the current module?

@jneira
Copy link
Member

jneira commented Jan 31, 2021

yeah, in fact we are doing it already and we only should remove the default extensions used by hlint
we have to analyze if it can have unintended effects

jneira added a commit to jneira/haskell-language-server that referenced this issue Nov 2, 2021
mergify bot pushed a commit that referenced this issue Nov 10, 2021
…#2321)

* Rename test data files

* Add regression tests

* Add regression test for #1279

* Use timeout

* Correct waitForProgressDone in ghcide

* Remove unnecessary waitForDiagnostics

* Mark test broken for hlint on ghclib

* Add test over unused extensions

* Add test for #2042

* Add data for #2280

* Use waitForAllProgressDone

* Add test for #2280

* correct module name

* Add reproduction for #2290

* Correct test case

* Comment about knownBrokenForHlint*

* Correction
@jneira
Copy link
Member

jneira commented Jan 31, 2022

This has a regression tes here:

, knownBrokenForHlintOnGhcLib "[#1279] hlint uses a fixed set of extensions" $
testCase "hlint should not activate extensions like PatternSynonyms" $ runHlintSession "" $ do
doc <- openDoc "PatternKeyword.hs" "haskell"
waitForAllProgressDone
-- hlint will report a parse error if PatternSynonyms is enabled
expectNoMoreDiagnostics 3 doc "hlint"

@jneira
Copy link
Member

jneira commented Jan 31, 2022

@eddiemundo do you think this could relativley easy to fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: hls-hlint-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