diff options
| author | Robert Griesemer <gri@golang.org> | 2022-12-06 14:43:39 -0800 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2023-01-17 19:54:25 +0000 |
| commit | b003ee499a97f28a1328a8eaeb380596fad5788b (patch) | |
| tree | 83c22e57a339db16f9ee03234744f16ed21c4fe6 /src/cmd/compile | |
| parent | 3af3810a3eeef49890b3cffb8d3f2a491f1b1b35 (diff) | |
| download | go-b003ee499a97f28a1328a8eaeb380596fad5788b.tar.xz | |
internal/types: consistently use double quotes around ERROR patterns
Before matching the pattern, the double quotes are simply stripped
(no Go string unquoting) for now. This is a first step towards use
of proper Go strings as ERROR patterns.
The changes were obtained through a couple of global regexp
find/replace commands:
/\* ERROR ([^"]+) \*/ => /* ERROR "$1" */
// ERROR ([^"]+)$ => // ERROR "$1"
followed up by manual fixes where multiple "/* ERROR"-style
errors appeared on the same line (in that case, the first
regexp matches the first and last ERROR).
For #51006.
Change-Id: Ib92c2d5e339075aeec1ea74c339b5fecf953d1a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/455718
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/cmd/compile')
| -rw-r--r-- | src/cmd/compile/internal/types2/check_test.go | 8 | ||||
| -rw-r--r-- | src/cmd/compile/internal/types2/testdata/local/issue47996.go | 2 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/types2/check_test.go b/src/cmd/compile/internal/types2/check_test.go index 611466ba01..6825133048 100644 --- a/src/cmd/compile/internal/types2/check_test.go +++ b/src/cmd/compile/internal/types2/check_test.go @@ -196,8 +196,14 @@ func testFiles(t *testing.T, filenames []string, colDelta uint, manual bool) { indices = indices[:0] for i, want := range errList { pattern := strings.TrimSpace(want.Msg[len(" ERROR "):]) + // We expect all patterns to be quoted in double quotes + // and then we remove the quotes. + // TODO(gri) use correct strconv.Unquote eventually if n := len(pattern); n >= 2 && pattern[0] == '"' && pattern[n-1] == '"' { pattern = pattern[1 : n-1] + } else { + t.Errorf("%s:%d:%d: unquoted pattern: %s", filename, line, want.Pos.Col(), pattern) + continue } rx, err := regexp.Compile(pattern) if err != nil { @@ -303,7 +309,7 @@ func TestCheck(t *testing.T) { } func TestSpec(t *testing.T) { testDirFiles(t, "../../../../internal/types/testdata/spec", 0, false) } func TestExamples(t *testing.T) { - testDirFiles(t, "../../../../internal/types/testdata/examples", 45, false) + testDirFiles(t, "../../../../internal/types/testdata/examples", 50, false) } // TODO(gri) narrow column tolerance func TestFixedbugs(t *testing.T) { testDirFiles(t, "../../../../internal/types/testdata/fixedbugs", 100, false) diff --git a/src/cmd/compile/internal/types2/testdata/local/issue47996.go b/src/cmd/compile/internal/types2/testdata/local/issue47996.go index 2c4b6610fe..6fb50a611b 100644 --- a/src/cmd/compile/internal/types2/testdata/local/issue47996.go +++ b/src/cmd/compile/internal/types2/testdata/local/issue47996.go @@ -5,4 +5,4 @@ package p // don't crash -func T /* ERROR missing */ [P] /* ERROR missing */ m /* ERROR unexpected */ () /* ERROR \) */ { /* ERROR { */ } /* ERROR } */ +func T /* ERROR "missing" */ [P] /* ERROR "missing" */ m /* ERROR "unexpected" */ () /* ERROR "\)" */ { /* ERROR "{" */ } /* ERROR "}" */ |
