proposal: go/types: publish Error.{Start,End} fields #71803
Labels
LibraryProposal
Issues describing a requested change to the Go standard library or x/ libraries, but not to a tool
Proposal
Milestone
Background: Since go1.16 (#42290), go/types has internally recorded three positions (start, pos, and end) for type errors. However, only the Pos field is exposed. The x/tools repo has long resorted to unsavory hacks such as reading the non-exported fields, and using heuristics on the source text (!) to guess the end position.
Proposal: We propose to publish the Start and End fields.
package types type Error struct { Fset *token.FileSet // file set for interpretation of Pos // Invariant: Start <= Pos < End || Start == Pos == End. Pos token.Pos // error position + Start, End token.Pos // start, end of containing expression Msg string // error message Soft bool // if set, error is "soft" }
@gri @findleyr
The text was updated successfully, but these errors were encountered: