go/parser: ast.File.File{Start,End} fields are uninitialized when parser bails out early #70162
Closed
Description
When the parser fails to parse even the package declaration, it bails out early, returning a nil *ast.File
. The calling code has a deferred function that replaces this nil with a mininally valid ast.File... except that it fails to populate the FileStart and FileEnd fields (my bad).
Example: https://go.dev/play/p/KtgnRPdgyPE
We should populate these fields in all cases:
FileStart: token.Pos(p.file.Base()),
FileEnd: token.Pos(p.file.Base() + p.file.Size()),
I will send a CL.
Metadata
Assignees
Labels
No labels