You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.