go/parser: StructType.End() can overflow the File #48300
Labels
gopls/parsing
Issues related to parsing / poor parser recovery.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
As encountered in #48249,
StructType.End()
can overflow the file (such thatFile.Offset
panics).This is due to the error recovery here:
https://cs.opensource.google/go/go/+/master:src/go/parser/parser.go;l=675;drc=0406d3a8e5301bd5fd697018e6e8fbb9c75eeb42
Which will set the
StructType.Fields.Closing
to the end of the file, and thenStructType.Fields.End
overflows:https://cs.opensource.google/go/go/+/master:src/go/ast/ast.go;l=252;drc=master
This is a low priority (the logic that gopls was using should have been more robust), but I feel like it should be an invariant of nodes that if
Pos()
orEnd()
is nottoken.NoPos
, they have a valid offset.Are there counter-arguments or contradicting precedent?
CC @griesemer @stamblerre
The text was updated successfully, but these errors were encountered: