Skip to content
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/gopls: vendor go/parser #45408

Open
findleyr opened this issue Apr 6, 2021 · 0 comments
Open

x/tools/gopls: vendor go/parser #45408

findleyr opened this issue Apr 6, 2021 · 0 comments
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

Comments

@findleyr
Copy link
Contributor

findleyr commented Apr 6, 2021

Gopls depends on go/parser error recovery, and has various targeted workarounds where go/parser error recovery is not sufficient (fixSrc, fixAST). It also has tests that assert on behavior in the presence of invalid syntax.

As we work on improving the built-in error recovery in go/parser, these workarounds and tests present a difficult target to hit across Go versions. The easiest solution for this is probably to vendor go/parser so that we have consistent parser behavior for all supported go versions.

Another consideration is that some of the changes to parser error recovery we want to make for gopls might not be suitable for upstreaming to go/parser. For example, it might make sense for gopls to attempt multiple error recovery modes and choose the result with the fewest errors / most parsed syntax. Something like that would be very hard to support in go/parser, where simplicity and efficiency are critical, and which (mostly) targets valid source. Conceivably we could have some methodology for maintaining a patch on top of go/parser, and/or adding extensibility points to go/parser.

This would not be without its downside: as we have seen with e.g. x/tools/go/internal/gcimporter, there is a non-trivial amount of work and risk associated with maintaining a copy. Nevertheless, on balance I think it's worth doing.

CC @stamblerre @heschi

@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Apr 6, 2021
@gopherbot gopherbot added this to the Unreleased milestone Apr 6, 2021
@findleyr findleyr self-assigned this Apr 6, 2021
@stamblerre stamblerre added this to To Do in gopls on-deck Apr 15, 2021
@stamblerre stamblerre moved this from To Do to P2 in gopls on-deck Aug 12, 2021
@findleyr findleyr added the gopls/parsing Issues related to parsing / poor parser recovery. label Jan 19, 2022
@findleyr findleyr removed their assignment Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
No open projects
Development

No branches or pull requests

3 participants