]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: remove support for "ERROR HERE" error markers in tests
authorRobert Griesemer <gri@golang.org>
Thu, 25 Aug 2022 20:48:42 +0000 (13:48 -0700)
committerGopher Robot <gobot@golang.org>
Thu, 25 Aug 2022 21:07:24 +0000 (21:07 +0000)
There are only two tests that rely on the "ERROR HERE" markers;
yet those tests are trivialy adjustable (by adding an explicit
semicolon) such that they can just use the "ERROR" markers.

For #54511.

Change-Id: Idbb96ca8d35ae2584d195a4ac7c92640b8b492c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/425674
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

src/go/types/check_test.go
src/go/types/testdata/check/stmt0.go

index f73133b867664879ad33c403a54457adf109b88e..8f7bbe4d0e2e5063c77368f1804521dcd875db98 100644 (file)
@@ -88,10 +88,8 @@ func parseFiles(t *testing.T, filenames []string, srcs [][]byte, mode parser.Mod
 
 // ERROR comments must start with text `ERROR "rx"` or `ERROR rx` where
 // rx is a regular expression that matches the expected error message.
-// Space around "rx" or rx is ignored. Use the form `ERROR HERE "rx"`
-// for error messages that are located immediately after rather than
-// at a token's position.
-var errRx = regexp.MustCompile(`^ *ERROR *(HERE)? *"?([^"]*)"?`)
+// Space around "rx" or rx is ignored.
+var errRx = regexp.MustCompile(`^ *ERROR *"?([^"]*)"?`)
 
 // errMap collects the regular expressions of ERROR comments found
 // in files and returns them as a map of error positions to error messages.
@@ -108,7 +106,6 @@ func errMap(t *testing.T, files []*ast.File, srcs [][]byte) map[string][]string
                var s scanner.Scanner
                s.Init(tok, src, nil, scanner.ScanComments)
                var prev token.Pos // position of last non-comment, non-semicolon token
-               var here token.Pos // position immediately after the token at position prev
 
        scanFile:
                for {
@@ -120,13 +117,9 @@ func errMap(t *testing.T, files []*ast.File, srcs [][]byte) map[string][]string
                                if lit[1] == '*' {
                                        lit = lit[:len(lit)-2] // strip trailing */
                                }
-                               if s := errRx.FindStringSubmatch(lit[2:]); len(s) == 3 {
-                                       pos := prev
-                                       if s[1] == "HERE" {
-                                               pos = here
-                                       }
-                                       p := fset.Position(pos).String()
-                                       errmap[p] = append(errmap[p], strings.TrimSpace(s[2]))
+                               if s := errRx.FindStringSubmatch(lit[2:]); len(s) == 2 {
+                                       p := fset.Position(prev).String()
+                                       errmap[p] = append(errmap[p], strings.TrimSpace(s[1]))
                                }
                        case token.SEMICOLON:
                                // ignore automatically inserted semicolon
@@ -136,13 +129,6 @@ func errMap(t *testing.T, files []*ast.File, srcs [][]byte) map[string][]string
                                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)
                        }
                }
        }
index b466ec8c601b9748733c26c22feeff287a212008..d8790b9616da834093146b67148e2e68bed484aa 100644 (file)
@@ -229,7 +229,7 @@ func selects() {
 }
 
 func gos() {
-       go 1 /* ERROR HERE "must be function call" */
+       go 1; /* ERROR "must be function call" */
        go int /* ERROR "go requires function call, not conversion" */ (0)
        go gos()
        var c chan int
@@ -238,7 +238,7 @@ func gos() {
 }
 
 func defers() {
-       defer 1 /* ERROR HERE "must be function call" */
+       defer 1; /* ERROR "must be function call" */
        defer int /* ERROR "defer requires function call, not conversion" */ (0)
        defer defers()
        var c chan int