Description
Hi! Here's a weird issue, as a treat for the connoisseurs π€
On a project that's using TH splices of the persistent
library, I'm reliably getting an extra stubborn "typecheck error" which is not real:
The names flagged as errors, RoleID
, UserId
, are defined in a TH splice, $(persistFileWith ...)
above in the same module. Full error as text:
Not in scope: type constructor or class βUserIdβ typecheck(GHC-76037)
I'm saying it is "not real" because:
stack build
compiles just fine, GHC itself is happy with the module. Making it hard to believe the displayed error being a genuine typecheck error coming from GHC.- Furthermore,
haskell-language-server-wrapper
succeeds when I invoke it directly on this module,Completed (1 file worked, 0 files failed)
.
As a triple-check, I can load this module in this project into Neovim equipped with an LSP client β and the module typechecks just fine as well, no fake not in scope
errors whatsoever:
Thus as shown, HLS itself seems alright β therefore I'm filing this onto the VSCode extension. β
These aren't making much sense to me, but the extension logs a good bunch of Rule Failed
messages:
and 3 Rule Failed
exceptions in devtools console as well:
At the very least, these Rule Failed
exceptions should not be translating into GHC-76037
a.k.a. NotInScope
diagnostics. I hope to be wrong here, but doing so is a big compromise to trustworthiness of the UI. π
Then as a secondary matter, the question remains, what's the cause of those exceptions in the first place.
Environment
OS: Ubuntu 24.04.2 LTS.
GHC, Stack, HLS β all from GHCup. I found multiple executables called haskell-language-server-wrapper
on this system, but also am reasonably certain that the only one that ever gets invoked is the ~/.ghcup/bin/haskell-language-server-wrapper
symlink.
HLS version: just rechecked on 2.10.0.0-p1
. This has also been happening on 2.9.0.1
with exact same symptoms.
GHC version: repro'd on 9.6.6 and today on 9.6.7.
IDE: VSCodium today's latest 1.99.32704.
Extension: vscode-haskell
2.6.0.
Steps to reproduce
Edit: Not quite minimal, but an isolated shareable repro case worked out β https://github.com/ulidtko/hls-issue4583-repro
I only see this issue in one specific project; minimizing a repro case seems a bit daunting. Didn't try yet.
Would appreciate further hints on what to try in this direction β perhaps it's an already known issue that I just couldn't find.
Workarounds
- Don't use VSCode π€· Works okay in NeoVIM for me.
- Within VSCode... none known so far.
From a few months of observation: the error does occasionally go away β when something, somehow, gets into caches. I couldn't spot what & in which cache exactly. Places I'm wiping clean now for experiment precision:
rm -rf ~/.cache/ghcide
, with HLS stopped, of course;git clean -fxd
in the project dir, which blows out the dust in.stack-work
,dist-newstyle
, etc.- the readme mentions that the extension has its own cache, in my case that's
~/.config/VSCodium/User/globalStorage/haskell.haskell/
β and on my machine, it's there but always empty.
Debug logs
haskell-language-server-wrapper --debug
β done, it produces a whole bunch of information I don't want to review & redact. It ends with Completed (1 file worked, 0 files failed) β i.e. there're no typecheck errors.
Re: extension specific log, already shown on the screenshots. There're pages upon pages, among which a lot of Rule Failed
errors like this one:
Extension log sample:
[Trace - 2:25:14 PM] Sending request 'textDocument/semanticTokens/full - (60)'.
2025-05-06T12:25:14.525852Z | Debug | semanticTokens: SemanticTokensConfig_: STC {stFunction = SemanticTokenTypes_Function, stVariable = SemanticTokenTypes_Variable, stDataConstructor = SemanticTokenTypes_EnumMember, stTypeVariable = SemanticTokenTypes_TypeParameter, stClassMethod = SemanticTokenTypes_Method, stPatternSynonym = SemanticTokenTypes_Macro, stTypeConstructor = SemanticTokenTypes_Enum, stClass = SemanticTokenTypes_Class, stTypeSynonym = SemanticTokenTypes_Type, stTypeFamily = SemanticTokenTypes_Interface, stRecordField = SemanticTokenTypes_Property, stModule = SemanticTokenTypes_Namespace, stOperator = SemanticTokenTypes_Operator}
2025-05-06T12:25:14.526202Z | Warning | semanticTokens: SemanticTokens' dependency error: Rule Failed: GetHieAst
2025-05-06T12:25:14.526442Z | Debug | LOOKUP PERSISTENT FOR: GetSemanticTokens
2025-05-06T12:25:14.526628Z | Debug | Finished: SemanticTokens.semanticTokensFull Took: 0.00s
2025-05-06T12:25:14.526788Z | Debug | semanticTokens: Rule Failed: GetSemanticTokens
[Trace - 2:25:14 PM] Received response 'textDocument/semanticTokens/full - (60)' in 5ms. Request failed: semanticTokens: Rule Failed: GetSemanticTokens (-32803).
[Error - 2:25:14 PM] Request textDocument/semanticTokens/full failed.
Message: semanticTokens: Rule Failed: GetSemanticTokens
Code: -32803
[Trace - 2:25:27 PM] Sending request 'textDocument/foldingRange - (61)'.
2025-05-06T12:25:27.492652Z | Debug | Finished: FoldingRange Took: 0.00s
2025-05-06T12:25:27.492763Z | Debug | codeRange: Rule Failed: GetCodeRange
[Trace - 2:25:27 PM] Received response 'textDocument/foldingRange - (61)' in 2ms. Request failed: codeRange: Rule Failed: GetCodeRange (-32803).
[Error - 2:25:27 PM] Request textDocument/foldingRange failed.
Message: codeRange: Rule Failed: GetCodeRange
Code: -32803
2025-05-06T12:25:49.092374Z | Info | Live bytes: 525.30MB Heap size: 2218.79MB
Kindly LMK what else to check.