-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gopls/internal/lsp/safetoken: fix bug in Offset at EOF
During parser error recovery, it may synthesize tokens such as RBRACE at EOF, causing the End position of the incomplete syntax nodes to be computed as Rbrace+len("}"), which is out of bounds, and would cause token.File.Offset to panic, or safetoken.Offset to return an error. This change is a workaround in gopls so that such End positions are considered valid, and are mapped to the end of the file. Also - a regression test. - remove safetoken.InRange, to avoid ambiguity. It was used in only one place (and dubiously even there). Fixes golang/go#57484 Updates golang/go#57490 Change-Id: I75bbe4f3b3c54aedf47a36649e8ee56bca205c8d Reviewed-on: https://go-review.googlesource.com/c/tools/+/459735 Run-TryBot: Alan Donovan <adonovan@google.com> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com>
- Loading branch information
Showing
4 changed files
with
65 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters