Skip to content

go/parser: ast.File.File{Start,End} fields are uninitialized when parser bails out early #70162

Closed
@adonovan

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
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions