x/tools/gopls: unexpected line/character calculations in certain diagnostics #40522
Labels
gopls/parsing
Issues related to parsing / poor parser recovery.
gopls
Issues related to the Go language server, gopls.
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
What did you do?
I've run into a situation where gopls was consistently returning a diagnostic with range data that was inconsistent with the editor state. Critically, it was producing a range with a character that was past the end of the line.
While I uncovered the issue interacting with gopls via the LSP interface, it appears to exhibit the behavior on the command line as well. Here's the code that reproduces the issue for me:
What did you expect to see?
The line at issue, which has an intentional error, is the
if ;
. When running gopls from the command line, I get the following (expected) output:file.go:8:2: expected operand, found '}'
However if I exchange that offending semi-colon for an
r
character, I get the following unexpected, and possibly incorrect, output:file.m:7:7: expected operand, found '}'
Not only is the line change surprising, the character offset is past the end of the line.
What did you see instead?
I would have expected the line/character output to be unchanged, or changed, but still consistent with the length of the line in question.
Build info
Go info
The text was updated successfully, but these errors were encountered: