-
-
Notifications
You must be signed in to change notification settings - Fork 391
Various Rule Failed
, shown as "Type constructor or class is not in scope (GHC-76037)" β yet the project compiles
#4583
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Hi thanks for the bug report! Even though you can only reproduce this issue with VSCode, it is pretty much impossible to be caused by the extension, iirc, we are not even installing an While I am not aware of any active bug reports, I do recall something similar happening in the past... What I can imagine is that stack and HLS get confused when TH is involved, perhaps you can try to compile your project using |
OK, thanks for acknowledgement @fendor π
Is this doable with just switching the
I think I understand that, yes π€ But how doesn't running |
No, I am afraid, you'd have to write that
It looks like the rule that is failing is Could you share the logs of your cli run? Maybe it includes more error messages. |
Hmmm π€ Well OK, some findings. One, I just tried copying the project to In HLS log of the extension, there was clearly re-typechecking of the problematic module happening (with e.g. collecting record-fields off the TH output) β and vscode showed 0 issues, too. @fendor is there some other cache I'm missing to clear? Another: my mistake was, doing This latter call:
So indeed, it's a purely HLS issue, extension isn't relevant. You were right in transferring it. |
Interesting, is anything special about the directory structure? E.g., spaces or unicode characters in the filepath?
No, I think you got them all.
Ok, that still sounds like we are doing something wrong with our handling of TH... cc @wz1000, might be interesting for you. In your example, are Small aside, is this project a mono repo? In the logs, it looks like there are around 6 executables, but no libs, does that sound possible? Also, are you using an hie.yaml? If no, could generate one with https://hackage.haskell.org/package/implicit-hie and share what the |
Nope, none of that, all printable ascii. The "weirdest" thing I can think of here, is that the persistent model file is without extension; meaning Also... I'm not entirely sure, but I think I noticed this issue started roughly at the same time when a teammate had changed import Database.Persist.Quasi (lowerCaseSettings)
import Database.Persist.TH (mkPersist, persistFileWith, share, sqlSettings)
share [mkPersist sqlSettings]
$(persistFileWith lowerCaseSettings (modelsDir <> "/security")) into import Database.Persist.Quasi (lowerCaseSettings)
import Database.Persist.TH (discoverEntities, mkPersistWith, persistFileWith, share, sqlSettings)
share [mkPersistWith sqlSettings $(discoverEntities)]
$(persistFileWith lowerCaseSettings (modelsDir <> "/security")) to fix another thing. This discoverEntities splice does do things to the module scope β so... might as well be relevant.
Yes. Those are Persistent's EntityKey's for entities
Potentially yes... but not easy. Hacking off 108 kLoC of haskell code won't be so easy I'm afraid π Not enthusiastic of starting that. I might better try to work out a repro case from scratch (from a template), if I'm lucky something shareable might come out.
Ahhh... no + yes? π In terms of packages, the stack.yaml says
Yes, a hand-written one. Output of implicit-hie
β misses a few details, and gets a few pieces wrong too; hence |
Unfortunately, I don't have any obvious ideas what might be going wrong. The smaller reproducer would probably help, or bisecting the changes on your project might also help us out. |
Aye, I minimized a standalone repro πΊ @fendor @wz1000 https://github.com/ulidtko/hls-issue4583-repro
|
Thanks, I can reproduce the issue! |
It seems like this issue is stack specific, at least with Could you confirm this behaviour as well? Opening |
Yep, indeed! Need to have a parallel buffer with a test component module open. Then it errors. |
We did not forget this issue, I talked to @wz1000, and we conjecture this issue is due to HLS's somewhat broken support for stack projects with multiple home units. |
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: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.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 intoGHC-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 on2.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
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.~/.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:
Kindly LMK what else to check.
The text was updated successfully, but these errors were encountered: