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

findleyr opened this issue Apr 6, 2021 · 0 comments

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

findleyr opened this issue Apr 6, 2021 · 0 comments


Copy link

@findleyr 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 this to the Unreleased milestone Apr 6, 2021
@findleyr findleyr self-assigned this Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants