-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/gopls: add logging to detect instances of "cannot use A (value of type B) as B value" #38403
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
Comments
Thanks for the report. I could see this happening with It's a cache invalidation issue where we end up type-checking a package with 2 different versions of one dependency (so somehow there are 2 "contexts" in this case). This is more likely to happen when you have a workspace structured like this: package a imports package b and package c Please do add more detail and a log if you see it again. The sequence of file changes will help us understand what steps are needed to repro. |
As I mention above, I don't have any repro steps as yet. When I do I'll try with and without remote. |
Quick update: I'm seeing this semi-regularly now, although still not able to 100% repro. The setup is roughly this:
Now I'm in the bad state. |
Thanks very much for the details. Couple questions: When you say 'no gopls currently running', you mean no session (i.e. forwarder), right? The daemon is running through all this? How do you get out of the bad state? Do you restart your session? Do you have to kill the daemon? |
No, I mean no remote. This was simply to indicate I'm starting from cold/fresh.
At the moment, quit all editor sessions and then |
@stamblerre This smells like the same bug? I was happily editing some tests when, suddenly, another file (which is fine and wasn't being edited) in the same test package started showing as erroring. The error was on an import line: gogo_proto "github.com/gogo/protobuf/proto"
^
"github.com/gogo/protobuf/proto" imported but not used as gogo_proto and also on this later line in the file: func assertMutationFailure(h *harness.Harness, namespace string, muts []*proto.Mutation, errorType gogo_proto.Message) {
^
Message not declared by package proto Log: gopls.log.gz. (Note: Had to scrub a lot of |
I can actually reproduce this error consistently, even across restarts. The file keeps getting the same error when editing other files. Let me know if there's anything I can do to get more diagnostics. |
@atombender, thank you for the report, and for attaching your logs. I'm not positive that your error is the same bug. How are you invoking gopls - which editor are you using and are which flags are you passing? @stamblerre and I discussed, and think this is probably unrelated to using |
Change https://golang.org/cl/232197 mentions this issue: |
VSCode. I just have |
I have a reasonable guess about what the cause of the bug is, so hopefully the CL above will be able to address it. @atombender: I do not think you're seeing the same issue, but unfortunately, I cannot make good sense of your log. Based on the changes you were making, it doesn't seem like |
@stamblerre Unfortunately, that was 5 days ago, and I'm not able to reproduce it right now, even if I reset my work back to that point in time. I will let you know if it happens again. |
@stamblerre I have a stack of CLs to rebase, but at that point I will try out this debugging CL and report back. |
Had one of these happen again. As before, I am using I wasn't editing that file when the error popped up. It showed up as I was editing a different file, I believe |
I have been able to isolate it in a repo that I'll share in a moment. |
Change https://golang.org/cl/232817 mentions this issue: |
Thank you very much for the repro. I think this is a different issue so I filed it separately: #38927. |
We just got a new report of this on Slack: https://gophers.slack.com/files/U15F7NXAQ/F014ZH71LCW/gopls.log?origin_team=T029RQSE6&origin_channel=CJZH85XCZ. |
Currently I have this occurring in 2 packages. One of the instances is a direct assignment of a concrete stdlib type on these 2 lines:
In another (not public) package, I have an issue with
|
This issue has popped up now and again, but it seems to be less prevalent these days. |
@heschik's rewrite of the cache has likely resolved this issue, especially since no one has seen it in months. Closing. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
This is a follow up to #38267 (comment).
I'm occasionally seeing instances of "cannot use A (value of type B) as B value" with
-remote
.The most recent instance was after I change branches, (with all editor instances closed) at which point I saw:
What did you expect to see?
No such errors
What did you see instead?
The above errors.
I don't have any repro steps as yet, nor any details that are worth uploading to this issue. So instead opening this as a placeholder in case others start seeing issues and can provide more context.
cc @stamblerre @findleyr
FYI @leitzler
The text was updated successfully, but these errors were encountered: