x/tools/gopls: compiler errors disappearing and reappearing in unopened test files #38267
Please answer these questions before submitting your issue. Thanks!
What did you do?
I was working on one file in a project that fully compiles and runs. I can publish it if needed.
What did you expect to see?
No errors; the code compiles.
What did you see instead?
Randomly, I'd see that one of the files had a bunch of compiler errors. But, I'd go open the file and they'd disappear. Close the file, and they'd come back. I could modify another file in the package and they'd disappear and come back some time in the future. This happens reliably in this project.
Screenshots of what VS Code is showing me in one file, versus moving to the file with the errors:
The text was updated successfully, but these errors were encountered:
Thanks for the issue report and the log! Some quick observations:
From this information, my first guess is that this is an issue with diagnostics caching, since the file is not changing, but the diagnostics are seemingly changing and being resent. I'll see if I can come up with a regression test for this case.
A question for you: Were the diagnostics ever correct? Are the analysis diagnostics accurate or are they also outdated?
I'm not sure which diagnostics you mean, sorry. Do you mean the "cannot use" ones? I don't think those were correct; the package builds and I can edit the file without trouble.
Which diagnostics are the analysis ones? Most (if not all) of the warnings are from golangci-lint (as I don't run staticcheck live). I'll have to disable it to get a better view on things, since all of these tools display their diagnostics with the underlying tool's/analysis' names. I know that this project has a bunch of places without
The repro is this repo on the selected branch, if you want to test this more easily: https://github.com/zikaeroh/sqlboiler/tree/with-gomod
The code for `gofmt -s` directly modifies the AST, since the ASTs are not long-lived. Some of this code made it into our analysis implementations, causing very strange bugs to manifest. Added a regression test for this specific case. Fixes golang/go#38267 Change-Id: I4c90cbd686f5e7e635a94abe40463feb5911fa2d
The code for `gofmt -s` directly modifies the AST, since the ASTs are not long-lived. Some of this code made it into our analysis implementations, causing very strange bugs to manifest. Added a regression test for this specific case. Fixes golang/go#38267 Change-Id: I235620adcbf2bbc7027c6d83ff2c7fe74729062e Reviewed-on: https://go-review.googlesource.com/c/tools/+/227299 Run-TryBot: Rebecca Stambler <email@example.com> TryBot-Result: Gobot Gobot <firstname.lastname@example.org> Reviewed-by: Heschi Kreinick <email@example.com> (cherry picked from commit 1fd9766) Reviewed-on: https://go-review.googlesource.com/c/tools/+/227354 Reviewed-by: Robert Findley <firstname.lastname@example.org>