go/parser: use (*Scanner).End in error testing

Updates #74958

Change-Id: I43dcbff6ec828bddf157b2e6ec80df526a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/738700
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
This commit is contained in:
Mateusz Poliwczak 2026-01-23 10:19:18 +01:00
parent 3c924059e6
commit 15882523a1

View file

@ -81,6 +81,8 @@ func expectedErrors(fset *token.FileSet, filename string, src []byte) map[token.
for {
pos, tok, lit := s.Scan()
end := s.End()
switch tok {
case token.EOF:
return errors
@ -104,13 +106,7 @@ func expectedErrors(fset *token.FileSet, filename string, src []byte) map[token.
fallthrough
default:
prev = pos
var l int // token length
if tok.IsLiteral() {
l = len(lit)
} else {
l = len(tok.String())
}
here = prev + token.Pos(l)
here = end
}
}
}