]> Cypherpunks repositories - gostls13.git/commitdiff
go/parser: use (*Scanner).End in error testing
authorMateusz Poliwczak <mpoliwczak34@gmail.com>
Fri, 23 Jan 2026 09:19:18 +0000 (10:19 +0100)
committerMateusz Poliwczak <mpoliwczak34@gmail.com>
Thu, 29 Jan 2026 06:44:26 +0000 (22:44 -0800)
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>
src/go/parser/error_test.go

index 252325659cb752133cad8c4df2d71eade00e3653..aa4fd6596270282db726539f3d5464edd6a271ad 100644 (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
                }
        }
 }