Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
go/parser: ParseExpr should return (partial) result even in case of an error #34211
What version of Go are you using (
parser.ParseExpr doesn't say anything about guaranteeing a nil ast.Expr when err != nil. Clients should be checking the error anyway, so it could still potentially be modified. Another option is to introduce a named type that is type-asserted for the src parameter in ParseExprFrom, like SrcWithOptions or something, but that might be gross.
If we do introduce a new API for a "reentrant" expression parser, an x/ repo like x/parserutil would be a good place. A "reentrant" parser could take a cursor like in astutil, which would allow it to keep track of state, e.g.