x/tools/gopls: vendor go/parser #45408
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
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
The text was updated successfully, but these errors were encountered: