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
x/tools/internal/lsp: panic: illegal Pos value #30155
Comments
I expect that the possibly invalid file caused goimports to return an invalid result, and so the text edit ranges were incorrect, causing this nil pointer. If you do see this again and are able to find a repro case, that would be very helpful here. |
The same thing happened to me today. It's reproducible in situ, but the files are part of a large project. |
The problem is at internal/lsp/format.go:50, where the edit.Range.End is 0. The code that causes this has a comment at the end of the file. The comment ends with |
Trying again: the comment at the end of the file is a blank, followed by a * followed by a slash followed by a newline. That comment causes edit.Range.End in lsp/format.go to be 0, which is illegal. Adding a // comment line to the end of the file fixes it. |
@pjweinb: the logic that causes this is going away in golang.org/cl/166884 with @ianthehat's new span library. I wonder if that will fix the issue. I'll try to repro after that CL goes in. |
I'm consistently getting the error on Here's the stacktrace
|
Change https://golang.org/cl/169440 mentions this issue: |
Yeah, I've noticed that as well, thank you for bringing it up. Sent out a CL which will hopefully fix it. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
I'm a couple of commits behind master on x/tools at time of writing (40960b6). I'm not testing on master because that fails due to #30154.
What did you do?
Compile
gopls
with-race
. Usecmd/gopls/forward
. Use vscode-go. I am working out of my$GOPATH
using modules, and haveGO111MODULE=on
.I was editing a fairly simple file at the time, it looked like this:
What did you expect to see?
gopls continues to function.
What did you see?
Crash.
I can't be sure the exact state the file was in at the time, nor my editor. I think there may have been a comma missing between
qux
andmux
. I'm uncertain if I had added the import declaration yet. I have made a quick attempt to reproduce but did not have any luck./cc @stamblerre
The text was updated successfully, but these errors were encountered: