Skip to content

Commit

Permalink
syntax: stop embedding Pos in error struct types
Browse files Browse the repository at this point in the history
Otherwise the error types gain methods like String or Offset,
which don't make any sense on an error as a whole.
Particularly String, as it won't stringify the entire error;
just its position, omitting the rest of the fields, unlike Error.

This is technically a breaking change, but I never intended the methods
to be included in the error types, and hopefully noone relies on that.
Anyone who relied on them likely got confused by my API mistake here,
and might have buggy code as a result of it.
  • Loading branch information
mvdan committed Jun 10, 2023
1 parent dfc1441 commit 6093166
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions syntax/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -803,8 +803,8 @@ func IsKeyword(word string) bool {
// the parser cannot recover.
type ParseError struct {
Filename string
Pos
Text string
Pos Pos
Text string

Incomplete bool
}
Expand All @@ -821,9 +821,9 @@ func (e ParseError) Error() string {
// in the current language variant, and what languages support it.
type LangError struct {
Filename string
Pos
Feature string
Langs []LangVariant
Pos Pos
Feature string
Langs []LangVariant
}

func (e LangError) Error() string {
Expand Down

0 comments on commit 6093166

Please sign in to comment.