From b003ee499a97f28a1328a8eaeb380596fad5788b Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Tue, 6 Dec 2022 14:43:39 -0800 Subject: [PATCH] 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 Reviewed-by: Robert Griesemer Run-TryBot: Robert Griesemer Reviewed-by: Robert Findley TryBot-Result: Gopher Robot --- src/cmd/compile/internal/types2/check_test.go | 8 +- .../types2/testdata/local/issue47996.go | 2 +- src/go/types/check_test.go | 12 +- src/go/types/issues_test.go | 8 +- src/internal/types/testdata/check/blank.go | 2 +- .../types/testdata/check/builtins0.go | 492 +++++++++--------- .../types/testdata/check/builtins1.go | 68 +-- src/internal/types/testdata/check/const0.go | 18 +- .../types/testdata/check/constdecl.go | 16 +- src/internal/types/testdata/check/cycles0.go | 66 +-- src/internal/types/testdata/check/cycles2.go | 10 +- src/internal/types/testdata/check/cycles3.go | 2 +- src/internal/types/testdata/check/cycles4.go | 2 +- src/internal/types/testdata/check/cycles5.go | 30 +- src/internal/types/testdata/check/decls0.go | 8 +- src/internal/types/testdata/check/decls1.go | 4 +- src/internal/types/testdata/check/decls4.go | 28 +- src/internal/types/testdata/check/errors.go | 42 +- src/internal/types/testdata/check/expr0.go | 10 +- src/internal/types/testdata/check/expr1.go | 72 +-- src/internal/types/testdata/check/expr2.go | 106 ++-- src/internal/types/testdata/check/expr3.go | 6 +- src/internal/types/testdata/check/go1_16.go | 2 +- src/internal/types/testdata/check/go1_19.go | 2 +- src/internal/types/testdata/check/go1_8.go | 2 +- src/internal/types/testdata/check/importC.go | 6 +- .../check/importdecl0/importdecl0b.go | 8 +- .../check/importdecl1/importdecl1b.go | 2 +- src/internal/types/testdata/check/init0.go | 40 +- src/internal/types/testdata/check/init1.go | 14 +- src/internal/types/testdata/check/init2.go | 52 +- src/internal/types/testdata/check/issues0.go | 142 ++--- src/internal/types/testdata/check/issues1.go | 26 +- src/internal/types/testdata/check/main0.go | 4 +- src/internal/types/testdata/check/map0.go | 2 +- .../types/testdata/check/methodsets.go | 4 +- src/internal/types/testdata/check/shifts.go | 4 +- src/internal/types/testdata/check/slices.go | 2 +- src/internal/types/testdata/check/stmt0.go | 110 ++-- .../types/testdata/check/typeinference.go | 24 +- .../types/testdata/check/typeinst0.go | 20 +- .../types/testdata/check/typeinst1.go | 40 +- .../types/testdata/check/typeparams.go | 140 ++--- src/internal/types/testdata/check/unions.go | 6 +- src/internal/types/testdata/check/vardecl.go | 16 +- .../types/testdata/examples/constraints.go | 30 +- .../types/testdata/examples/functions.go | 30 +- .../types/testdata/examples/inference.go | 14 +- .../types/testdata/examples/methods.go | 10 +- .../types/testdata/examples/operations.go | 6 +- src/internal/types/testdata/examples/types.go | 62 +-- .../types/testdata/examples/typesets.go | 8 +- .../types/testdata/fixedbugs/54942.go | 4 +- .../types/testdata/fixedbugs/issue20583.go | 8 +- .../types/testdata/fixedbugs/issue28251.go | 6 +- .../types/testdata/fixedbugs/issue39634.go | 58 +-- .../types/testdata/fixedbugs/issue39664.go | 2 +- .../types/testdata/fixedbugs/issue39693.go | 2 +- .../types/testdata/fixedbugs/issue39699.go | 6 +- .../types/testdata/fixedbugs/issue39723.go | 2 +- .../types/testdata/fixedbugs/issue39725.go | 4 +- .../types/testdata/fixedbugs/issue39754.go | 4 +- .../types/testdata/fixedbugs/issue39768.go | 6 +- .../types/testdata/fixedbugs/issue39938.go | 6 +- .../types/testdata/fixedbugs/issue39948.go | 2 +- .../types/testdata/fixedbugs/issue39976.go | 2 +- .../types/testdata/fixedbugs/issue40056.go | 4 +- .../types/testdata/fixedbugs/issue40057.go | 2 +- .../types/testdata/fixedbugs/issue40350.go | 2 +- .../types/testdata/fixedbugs/issue40684.go | 4 +- .../types/testdata/fixedbugs/issue41124.go | 44 +- .../types/testdata/fixedbugs/issue42695.go | 12 +- .../types/testdata/fixedbugs/issue42758.go | 4 +- .../types/testdata/fixedbugs/issue42881.go | 6 +- .../types/testdata/fixedbugs/issue42987.go | 2 +- .../types/testdata/fixedbugs/issue43087.go | 10 +- .../types/testdata/fixedbugs/issue43109.go | 2 +- .../types/testdata/fixedbugs/issue43110.go | 8 +- .../types/testdata/fixedbugs/issue43124.go | 4 +- .../types/testdata/fixedbugs/issue43125.go | 4 +- .../types/testdata/fixedbugs/issue43190.go | 18 +- .../types/testdata/fixedbugs/issue43527.go | 4 +- .../types/testdata/fixedbugs/issue43671.go | 8 +- .../types/testdata/fixedbugs/issue45114.go | 2 +- .../types/testdata/fixedbugs/issue45550.go | 2 +- .../types/testdata/fixedbugs/issue45635.go | 2 +- .../types/testdata/fixedbugs/issue45639.go | 4 +- .../types/testdata/fixedbugs/issue45920.go | 4 +- .../types/testdata/fixedbugs/issue46090.go | 2 +- .../types/testdata/fixedbugs/issue46403.go | 2 +- .../types/testdata/fixedbugs/issue46461.go | 6 +- .../types/testdata/fixedbugs/issue46583.go | 8 +- .../types/testdata/fixedbugs/issue47031.go | 2 +- .../types/testdata/fixedbugs/issue47115.go | 8 +- .../types/testdata/fixedbugs/issue47127.go | 32 +- .../types/testdata/fixedbugs/issue47411.go | 10 +- .../types/testdata/fixedbugs/issue47747.go | 4 +- .../types/testdata/fixedbugs/issue47796.go | 14 +- .../types/testdata/fixedbugs/issue47818.go | 38 +- .../types/testdata/fixedbugs/issue47968.go | 8 +- .../types/testdata/fixedbugs/issue48008.go | 24 +- .../types/testdata/fixedbugs/issue48018.go | 2 +- .../types/testdata/fixedbugs/issue48048.go | 4 +- .../types/testdata/fixedbugs/issue48082.go | 2 +- .../types/testdata/fixedbugs/issue48083.go | 2 +- .../types/testdata/fixedbugs/issue48136.go | 14 +- .../types/testdata/fixedbugs/issue48312.go | 6 +- .../types/testdata/fixedbugs/issue48472.go | 4 +- .../types/testdata/fixedbugs/issue48529.go | 2 +- .../types/testdata/fixedbugs/issue48582.go | 10 +- .../types/testdata/fixedbugs/issue48619.go | 4 +- .../types/testdata/fixedbugs/issue48656.go | 2 +- .../types/testdata/fixedbugs/issue48703.go | 2 +- .../types/testdata/fixedbugs/issue48712.go | 22 +- .../types/testdata/fixedbugs/issue48819.go | 2 +- .../types/testdata/fixedbugs/issue48951.go | 14 +- .../types/testdata/fixedbugs/issue48962.go | 2 +- .../types/testdata/fixedbugs/issue48974.go | 2 +- .../types/testdata/fixedbugs/issue49003.go | 2 +- .../types/testdata/fixedbugs/issue49005.go | 8 +- .../types/testdata/fixedbugs/issue49043.go | 4 +- .../types/testdata/fixedbugs/issue49112.go | 4 +- .../types/testdata/fixedbugs/issue49179.go | 8 +- .../types/testdata/fixedbugs/issue49242.go | 10 +- .../types/testdata/fixedbugs/issue49247.go | 4 +- .../types/testdata/fixedbugs/issue49276.go | 10 +- .../types/testdata/fixedbugs/issue49296.go | 8 +- .../types/testdata/fixedbugs/issue49439.go | 8 +- .../types/testdata/fixedbugs/issue49482.go | 2 +- .../types/testdata/fixedbugs/issue49541.go | 4 +- .../types/testdata/fixedbugs/issue49579.go | 2 +- .../types/testdata/fixedbugs/issue49602.go | 6 +- .../types/testdata/fixedbugs/issue49735.go | 6 +- .../types/testdata/fixedbugs/issue49739.go | 6 +- .../types/testdata/fixedbugs/issue49864.go | 2 +- .../types/testdata/fixedbugs/issue50321.go | 2 +- .../types/testdata/fixedbugs/issue50372.go | 10 +- .../types/testdata/fixedbugs/issue50417.go | 30 +- .../types/testdata/fixedbugs/issue50516.go | 4 +- .../types/testdata/fixedbugs/issue50646.go | 12 +- .../types/testdata/fixedbugs/issue50779.go | 2 +- .../types/testdata/fixedbugs/issue50782.go | 4 +- .../types/testdata/fixedbugs/issue50816.go | 4 +- .../types/testdata/fixedbugs/issue50912.go | 10 +- .../types/testdata/fixedbugs/issue50918.go | 4 +- .../types/testdata/fixedbugs/issue50929.go | 18 +- .../types/testdata/fixedbugs/issue50965.go | 4 +- .../types/testdata/fixedbugs/issue51025.go | 10 +- .../types/testdata/fixedbugs/issue51145.go | 8 +- .../types/testdata/fixedbugs/issue51229.go | 8 +- .../types/testdata/fixedbugs/issue51232.go | 10 +- .../types/testdata/fixedbugs/issue51233.go | 8 +- .../types/testdata/fixedbugs/issue51257.go | 8 +- .../types/testdata/fixedbugs/issue51335.go | 4 +- .../types/testdata/fixedbugs/issue51339.go | 6 +- .../types/testdata/fixedbugs/issue51360.go | 10 +- .../types/testdata/fixedbugs/issue51376.go | 4 +- .../types/testdata/fixedbugs/issue51472.go | 12 +- .../types/testdata/fixedbugs/issue51509.go | 2 +- .../types/testdata/fixedbugs/issue51525.go | 12 +- .../types/testdata/fixedbugs/issue51533.go | 4 +- .../types/testdata/fixedbugs/issue51578.go | 4 +- .../types/testdata/fixedbugs/issue51593.go | 2 +- .../types/testdata/fixedbugs/issue51607.go | 20 +- .../types/testdata/fixedbugs/issue51610.go | 2 +- .../types/testdata/fixedbugs/issue51658.go | 8 +- .../types/testdata/fixedbugs/issue51877.go | 8 +- .../types/testdata/fixedbugs/issue52401.go | 4 +- .../types/testdata/fixedbugs/issue52698.go | 2 +- .../types/testdata/fixedbugs/issue52915.go | 4 +- .../types/testdata/fixedbugs/issue53358.go | 6 +- .../types/testdata/fixedbugs/issue54280.go | 2 +- .../types/testdata/fixedbugs/issue54405.go | 4 +- .../types/testdata/fixedbugs/issue56351.go | 2 +- .../types/testdata/fixedbugs/issue56665.go | 6 +- .../types/testdata/fixedbugs/issue57500.go | 2 +- .../types/testdata/fixedbugs/issue6977.go | 8 +- .../types/testdata/spec/assignability.go | 70 +-- .../types/testdata/spec/comparable.go | 4 +- .../types/testdata/spec/comparable1.19.go | 12 +- .../types/testdata/spec/comparisons.go | 76 +-- .../types/testdata/spec/conversions.go | 48 +- .../types/testdata/spec/oldcomparable.go | 12 +- 183 files changed, 1490 insertions(+), 1478 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 "}" */ diff --git a/src/go/types/check_test.go b/src/go/types/check_test.go index 4d27f3629a..ea742f2b90 100644 --- a/src/go/types/check_test.go +++ b/src/go/types/check_test.go @@ -208,8 +208,14 @@ func testFiles(t *testing.T, sizes Sizes, filenames []string, srcs [][]byte, man indices = indices[:0] for i, want := range errList { pattern := strings.TrimSpace(want.text[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.col, pattern) + continue } rx, err := regexp.Compile(pattern) if err != nil { @@ -320,7 +326,7 @@ func TestManual(t *testing.T) { } func TestLongConstants(t *testing.T) { - format := "package longconst\n\nconst _ = %s /* ERROR constant overflow */ \nconst _ = %s // ERROR excessively long constant" + format := `package longconst; const _ = %s /* ERROR "constant overflow" */; const _ = %s // ERROR "excessively long constant"` src := fmt.Sprintf(format, strings.Repeat("1", 9999), strings.Repeat("1", 10001)) testFiles(t, nil, []string{"longconst.go"}, [][]byte{[]byte(src)}, false, nil) } @@ -329,14 +335,14 @@ func TestLongConstants(t *testing.T) { // be representable as int even if they already have a type that can // represent larger values. func TestIndexRepresentability(t *testing.T) { - const src = "package index\n\nvar s []byte\nvar _ = s[int64 /* ERROR \"int64\\(1\\) << 40 \\(.*\\) overflows int\" */ (1) << 40]" + const src = `package index; var s []byte; var _ = s[int64 /* ERROR "int64\(1\) << 40 \(.*\) overflows int" */ (1) << 40]` testFiles(t, &StdSizes{4, 4}, []string{"index.go"}, [][]byte{[]byte(src)}, false, nil) } func TestIssue47243_TypedRHS(t *testing.T) { // The RHS of the shift expression below overflows uint on 32bit platforms, // but this is OK as it is explicitly typed. - const src = "package issue47243\n\nvar a uint64; var _ = a << uint64(4294967296)" // uint64(1<<32) + const src = `package issue47243; var a uint64; var _ = a << uint64(4294967296)` // uint64(1<<32) testFiles(t, &StdSizes{4, 4}, []string{"p.go"}, [][]byte{[]byte(src)}, false, nil) } diff --git a/src/go/types/issues_test.go b/src/go/types/issues_test.go index b4845b1def..cbd6ca29e9 100644 --- a/src/go/types/issues_test.go +++ b/src/go/types/issues_test.go @@ -574,7 +574,7 @@ import ( func _() { // Packages should be fully qualified when there is ambiguity within the // error string itself. - a.F(template /* ERROR cannot use.*html/template.* as .*text/template */ .Template{}) + a.F(template /* ERROR "cannot use.*html/template.* as .*text/template" */ .Template{}) } ` csrc = ` @@ -587,12 +587,12 @@ import ( ) // Issue #46905: make sure template is not the first package qualified. -var _ fmt.Stringer = 1 // ERROR cannot use 1.*as fmt\.Stringer +var _ fmt.Stringer = 1 // ERROR "cannot use 1.*as fmt\.Stringer" // Packages should be fully qualified when there is ambiguity in reachable // packages. In this case both a (and for that matter html/template) import // text/template. -func _() { a.G(template /* ERROR cannot use .*html/template.*Template */ .Template{}) } +func _() { a.G(template /* ERROR "cannot use .*html/template.*Template" */ .Template{}) } ` tsrc = ` @@ -603,7 +603,7 @@ import "text/template" type T int // Verify that the current package name also causes disambiguation. -var _ T = template /* ERROR cannot use.*text/template.* as T value */.Template{} +var _ T = template /* ERROR "cannot use.*text/template.* as T value" */.Template{} ` ) diff --git a/src/internal/types/testdata/check/blank.go b/src/internal/types/testdata/check/blank.go index 6a2507f482..2bea11f53b 100644 --- a/src/internal/types/testdata/check/blank.go +++ b/src/internal/types/testdata/check/blank.go @@ -2,4 +2,4 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package _ /* ERROR invalid package name */ +package _ /* ERROR "invalid package name" */ diff --git a/src/internal/types/testdata/check/builtins0.go b/src/internal/types/testdata/check/builtins0.go index b54d339069..08b6004d1e 100644 --- a/src/internal/types/testdata/check/builtins0.go +++ b/src/internal/types/testdata/check/builtins0.go @@ -14,38 +14,38 @@ func append1() { var b byte var x int var s []byte - _ = append() // ERROR not enough arguments - _ = append("foo" /* ERROR must be a slice */ ) - _ = append(nil /* ERROR must be a slice */ , s) - _ = append(x /* ERROR must be a slice */ , s) + _ = append() // ERROR "not enough arguments" + _ = append("foo" /* ERROR "must be a slice" */ ) + _ = append(nil /* ERROR "must be a slice" */ , s) + _ = append(x /* ERROR "must be a slice" */ , s) _ = append(s) _ = append(s, nil...) - append /* ERROR not used */ (s) + append /* ERROR "not used" */ (s) _ = append(s, b) - _ = append(s, x /* ERROR cannot use x */ ) - _ = append(s, s /* ERROR cannot use s */ ) - _ = append(s...) /* ERROR not enough arguments */ - _ = append(s, b, s /* ERROR too many arguments */ ...) + _ = append(s, x /* ERROR "cannot use x" */ ) + _ = append(s, s /* ERROR "cannot use s" */ ) + _ = append(s...) /* ERROR "not enough arguments" */ + _ = append(s, b, s /* ERROR "too many arguments" */ ...) _ = append(s, 1, 2, 3) - _ = append(s, 1, 2, 3, x /* ERROR cannot use x */ , 5, 6, 6) - _ = append(s, 1, 2 /* ERROR too many arguments */, s...) + _ = append(s, 1, 2, 3, x /* ERROR "cannot use x" */ , 5, 6, 6) + _ = append(s, 1, 2 /* ERROR "too many arguments" */, s...) _ = append([]interface{}(nil), 1, 2, "foo", x, 3.1425, false) type S []byte type T string var t T - _ = append(s, "foo" /* ERROR cannot use .* in argument to append */ ) + _ = append(s, "foo" /* ERROR "cannot use .* in argument to append" */ ) _ = append(s, "foo"...) - _ = append(S(s), "foo" /* ERROR cannot use .* in argument to append */ ) + _ = append(S(s), "foo" /* ERROR "cannot use .* in argument to append" */ ) _ = append(S(s), "foo"...) - _ = append(s, t /* ERROR cannot use t */ ) + _ = append(s, t /* ERROR "cannot use t" */ ) _ = append(s, t...) _ = append(s, T("foo")...) - _ = append(S(s), t /* ERROR cannot use t */ ) + _ = append(S(s), t /* ERROR "cannot use t" */ ) _ = append(S(s), t...) _ = append(S(s), T("foo")...) - _ = append([]string{}, t /* ERROR cannot use t */ , "foo") + _ = append([]string{}, t /* ERROR "cannot use t" */ , "foo") _ = append([]T{}, t, "foo") } @@ -72,27 +72,27 @@ func append3() { f3 := func() (s []int, x, y int) { return } f5 := func() (s []interface{}, x int, y float32, z string, b bool) { return } ff := func() (int, float32) { return 0, 0 } - _ = append(f0 /* ERROR used as value */ ()) + _ = append(f0 /* ERROR "used as value" */ ()) _ = append(f1()) _ = append(f2()) _ = append(f3()) _ = append(f5()) - _ = append(ff /* ERROR must be a slice */ ()) // TODO(gri) better error message + _ = append(ff /* ERROR "must be a slice" */ ()) // TODO(gri) better error message } func cap1() { var a [10]bool var p *[20]int var c chan string - _ = cap() // ERROR not enough arguments - _ = cap(1, 2) // ERROR too many arguments - _ = cap(42 /* ERROR invalid */) + _ = cap() // ERROR "not enough arguments" + _ = cap(1, 2) // ERROR "too many arguments" + _ = cap(42 /* ERROR "invalid" */) const _3 = cap(a) assert(_3 == 10) const _4 = cap(p) assert(_4 == 20) _ = cap(c) - cap /* ERROR not used */ (c) + cap /* ERROR "not used" */ (c) // issue 4744 type T struct{ a [10]int } @@ -100,17 +100,17 @@ func cap1() { var s [][]byte _ = cap(s) - _ = cap(s... /* ERROR invalid use of \.\.\. */ ) + _ = cap(s... /* ERROR "invalid use of \.\.\." */ ) } func cap2() { f1a := func() (a [10]int) { return } f1s := func() (s []int) { return } f2 := func() (s []int, x int) { return } - _ = cap(f0 /* ERROR used as value */ ()) + _ = cap(f0 /* ERROR "used as value" */ ()) _ = cap(f1a()) _ = cap(f1s()) - _ = cap(f2()) // ERROR too many arguments + _ = cap(f2()) // ERROR "too many arguments" } // test cases for issue 7387 @@ -120,8 +120,8 @@ func cap3() { const ( _ = cap([4]int{}) _ = cap([4]int{x}) - _ = cap /* ERROR not constant */ ([4]int{f()}) - _ = cap /* ERROR not constant */ ([4]int{cap([]int{})}) + _ = cap /* ERROR "not constant" */ ([4]int{f()}) + _ = cap /* ERROR "not constant" */ ([4]int{cap([]int{})}) _ = cap([4]int{cap([4]int{})}) ) var y float64 @@ -130,12 +130,12 @@ func cap3() { _ = cap([4]float64{}) _ = cap([4]float64{y}) _ = cap([4]float64{real(2i)}) - _ = cap /* ERROR not constant */ ([4]float64{real(z)}) + _ = cap /* ERROR "not constant" */ ([4]float64{real(z)}) ) var ch chan [10]int const ( - _ = cap /* ERROR not constant */ (<-ch) - _ = cap /* ERROR not constant */ ([4]int{(<-ch)[0]}) + _ = cap /* ERROR "not constant" */ (<-ch) + _ = cap /* ERROR "not constant" */ ([4]int{(<-ch)[0]}) ) } @@ -143,7 +143,7 @@ func clear1() { var a [10]int var m map[float64]string var s []byte - clear(a /* ERROR cannot clear a */) + clear(a /* ERROR "cannot clear a" */) clear(&a) clear(m) clear(s) @@ -153,23 +153,23 @@ func clear1() { func close1() { var c chan int var r <-chan int - close() // ERROR not enough arguments - close(1, 2) // ERROR too many arguments - close(42 /* ERROR cannot close non-channel */) - close(r /* ERROR receive-only channel */) + close() // ERROR "not enough arguments" + close(1, 2) // ERROR "too many arguments" + close(42 /* ERROR "cannot close non-channel" */) + close(r /* ERROR "receive-only channel" */) close(c) - _ = close /* ERROR used as value */ (c) + _ = close /* ERROR "used as value" */ (c) var s []chan int - close(s... /* ERROR invalid use of \.\.\. */ ) + close(s... /* ERROR "invalid use of \.\.\." */ ) } func close2() { f1 := func() (ch chan int) { return } f2 := func() (ch chan int, x int) { return } - close(f0 /* ERROR used as value */ ()) + close(f0 /* ERROR "used as value" */ ()) close(f1()) - close(f2()) // ERROR too many arguments + close(f2()) // ERROR "too many arguments" } func complex1() { @@ -178,16 +178,16 @@ func complex1() { var f64 float64 var c64 complex64 var c128 complex128 - _ = complex() // ERROR not enough arguments - _ = complex(1) // ERROR not enough arguments - _ = complex(true /* ERROR mismatched types */ , 0) - _ = complex(i32 /* ERROR expected floating-point */ , 0) - _ = complex("foo" /* ERROR mismatched types */ , 0) - _ = complex(c64 /* ERROR expected floating-point */ , 0) - _ = complex(0 /* ERROR mismatched types */ , true) - _ = complex(0 /* ERROR expected floating-point */ , i32) - _ = complex(0 /* ERROR mismatched types */ , "foo") - _ = complex(0 /* ERROR expected floating-point */ , c64) + _ = complex() // ERROR "not enough arguments" + _ = complex(1) // ERROR "not enough arguments" + _ = complex(true /* ERROR "mismatched types" */ , 0) + _ = complex(i32 /* ERROR "expected floating-point" */ , 0) + _ = complex("foo" /* ERROR "mismatched types" */ , 0) + _ = complex(c64 /* ERROR "expected floating-point" */ , 0) + _ = complex(0 /* ERROR "mismatched types" */ , true) + _ = complex(0 /* ERROR "expected floating-point" */ , i32) + _ = complex(0 /* ERROR "mismatched types" */ , "foo") + _ = complex(0 /* ERROR "expected floating-point" */ , c64) _ = complex(f32, f32) _ = complex(f32, 1) _ = complex(f32, 1.0) @@ -196,17 +196,17 @@ func complex1() { _ = complex(f64, 1) _ = complex(f64, 1.0) _ = complex(f64, 'a') - _ = complex(f32 /* ERROR mismatched types */ , f64) - _ = complex(f64 /* ERROR mismatched types */ , f32) + _ = complex(f32 /* ERROR "mismatched types" */ , f64) + _ = complex(f64 /* ERROR "mismatched types" */ , f32) _ = complex(1, 1) _ = complex(1, 1.1) _ = complex(1, 'a') - complex /* ERROR not used */ (1, 2) + complex /* ERROR "not used" */ (1, 2) var _ complex64 = complex(f32, f32) - var _ complex64 = complex /* ERROR cannot use .* in variable declaration */ (f64, f64) + var _ complex64 = complex /* ERROR "cannot use .* in variable declaration" */ (f64, f64) - var _ complex128 = complex /* ERROR cannot use .* in variable declaration */ (f32, f32) + var _ complex128 = complex /* ERROR "cannot use .* in variable declaration" */ (f32, f32) var _ complex128 = complex(f64, f64) // untyped constants @@ -218,14 +218,14 @@ func complex1() { const _ = complex(0i, 0) const _ int = 1.0 + complex(1, 0i) - const _ int = complex /* ERROR int */ (1.1, 0) - const _ float32 = complex /* ERROR float32 */ (1, 2) + const _ int = complex /* ERROR "int" */ (1.1, 0) + const _ float32 = complex /* ERROR "float32" */ (1, 2) // untyped values var s uint - _ = complex(1 /* ERROR integer */ <> y } @@ -54,9 +54,9 @@ type myuint uint func _(x, y uint, z myuint) { x = x + 1 - x = x + - /* ERROR overflows uint */ 1 + x = x + - /* ERROR "overflows uint" */ 1 x = x + 1.0 - x = x + 1.1 // ERROR truncated to uint + x = x + 1.1 // ERROR "truncated to uint" x = x + y x = x - y x = x * y @@ -66,14 +66,14 @@ func _(x, y uint, z myuint) { x = x >> y z = z + 1 - z = x + - /* ERROR overflows uint */ 1 + z = x + - /* ERROR "overflows uint" */ 1 z = z + 1.0 - z = z + 1.1 // ERROR truncated to uint - z = z /* ERROR mismatched types */ + y - z = z /* ERROR mismatched types */ - y - z = z /* ERROR mismatched types */ * y - z = z /* ERROR mismatched types */ / y - z = z /* ERROR mismatched types */ % y + z = z + 1.1 // ERROR "truncated to uint" + z = z /* ERROR "mismatched types" */ + y + z = z /* ERROR "mismatched types" */ - y + z = z /* ERROR "mismatched types" */ * y + z = z /* ERROR "mismatched types" */ / y + z = z /* ERROR "mismatched types" */ % y z = z << y z = z >> y } @@ -89,39 +89,39 @@ func _(x, y float64, z myfloat64) { x = x - y x = x * y x = x / y - x = x /* ERROR not defined */ % y - x = x /* ERROR operand x .* must be integer */ << y - x = x /* ERROR operand x .* must be integer */ >> y + x = x /* ERROR "not defined" */ % y + x = x /* ERROR "operand x .* must be integer" */ << y + x = x /* ERROR "operand x .* must be integer" */ >> y z = z + 1 z = z + -1 z = z + 1.0 z = z + 1.1 - z = z /* ERROR mismatched types */ + y - z = z /* ERROR mismatched types */ - y - z = z /* ERROR mismatched types */ * y - z = z /* ERROR mismatched types */ / y - z = z /* ERROR mismatched types */ % y - z = z /* ERROR operand z .* must be integer */ << y - z = z /* ERROR operand z .* must be integer */ >> y + z = z /* ERROR "mismatched types" */ + y + z = z /* ERROR "mismatched types" */ - y + z = z /* ERROR "mismatched types" */ * y + z = z /* ERROR "mismatched types" */ / y + z = z /* ERROR "mismatched types" */ % y + z = z /* ERROR "operand z .* must be integer" */ << y + z = z /* ERROR "operand z .* must be integer" */ >> y } type mystring string func _(x, y string, z mystring) { x = x + "foo" - x = x /* ERROR not defined */ - "foo" - x = x /* ERROR mismatched types string and untyped int */ + 1 + x = x /* ERROR "not defined" */ - "foo" + x = x /* ERROR "mismatched types string and untyped int" */ + 1 x = x + y - x = x /* ERROR not defined */ - y - x = x /* ERROR mismatched types string and untyped int */* 10 + x = x /* ERROR "not defined" */ - y + x = x /* ERROR "mismatched types string and untyped int" */* 10 } func f() (a, b int) { return } func _(x int) { - _ = f /* ERROR multiple-value f */ () + 1 - _ = x + f /* ERROR multiple-value f */ () - _ = f /* ERROR multiple-value f */ () + f - _ = f /* ERROR multiple-value f */ () + f /* ERROR multiple-value f */ () + _ = f /* ERROR "multiple-value f" */ () + 1 + _ = x + f /* ERROR "multiple-value f" */ () + _ = f /* ERROR "multiple-value f" */ () + f + _ = f /* ERROR "multiple-value f" */ () + f /* ERROR "multiple-value f" */ () } diff --git a/src/internal/types/testdata/check/expr2.go b/src/internal/types/testdata/check/expr2.go index 1929664128..b00cfc21f8 100644 --- a/src/internal/types/testdata/check/expr2.go +++ b/src/internal/types/testdata/check/expr2.go @@ -9,8 +9,8 @@ package expr2 func _bool() { const t = true == true const f = true == false - _ = t /* ERROR operator .* not defined */ < f - _ = 0 == t /* ERROR mismatched types untyped int and untyped bool */ + _ = t /* ERROR "operator .* not defined" */ < f + _ = 0 == t /* ERROR "mismatched types untyped int and untyped bool" */ var b bool var x, y float32 b = x < y @@ -20,7 +20,7 @@ func _bool() { // corner cases var ( - v0 = nil == nil // ERROR operator == not defined on untyped nil + v0 = nil == nil // ERROR "operator == not defined on untyped nil" ) func arrays() { @@ -28,8 +28,8 @@ func arrays() { var a, b [10]int _ = a == b _ = a != b - _ = a /* ERROR < not defined */ < b - _ = a == nil /* ERROR mismatched types */ + _ = a /* ERROR "< not defined" */ < b + _ = a == nil /* ERROR "mismatched types" */ type C [10]int var c C @@ -37,10 +37,10 @@ func arrays() { type D [10]int var d D - _ = c == d /* ERROR mismatched types */ + _ = c == d /* ERROR "mismatched types" */ var e [10]func() int - _ = e /* ERROR \[10\]func\(\) int cannot be compared */ == e + _ = e /* ERROR "\[10\]func\(\) int cannot be compared" */ == e } func structs() { @@ -52,8 +52,8 @@ func structs() { } _ = s == t _ = s != t - _ = s /* ERROR < not defined */ < t - _ = s == nil /* ERROR mismatched types */ + _ = s /* ERROR "< not defined" */ < t + _ = s == nil /* ERROR "mismatched types" */ type S struct { x int @@ -68,23 +68,23 @@ func structs() { var ss S var tt T _ = s == ss - _ = ss == tt /* ERROR mismatched types */ + _ = ss == tt /* ERROR "mismatched types" */ var u struct { x int a [10]map[string]int } - _ = u /* ERROR cannot be compared */ == u + _ = u /* ERROR "cannot be compared" */ == u } func pointers() { // nil - _ = nil == nil // ERROR operator == not defined on untyped nil - _ = nil != nil // ERROR operator != not defined on untyped nil - _ = nil /* ERROR < not defined */ < nil - _ = nil /* ERROR <= not defined */ <= nil - _ = nil /* ERROR > not defined */ > nil - _ = nil /* ERROR >= not defined */ >= nil + _ = nil == nil // ERROR "operator == not defined on untyped nil" + _ = nil != nil // ERROR "operator != not defined on untyped nil" + _ = nil /* ERROR "< not defined" */ < nil + _ = nil /* ERROR "<= not defined" */ <= nil + _ = nil /* ERROR "> not defined" */ > nil + _ = nil /* ERROR ">= not defined" */ >= nil // basics var p, q *int @@ -96,10 +96,10 @@ func pointers() { _ = nil == q _ = nil != q - _ = p /* ERROR < not defined */ < q - _ = p /* ERROR <= not defined */ <= q - _ = p /* ERROR > not defined */ > q - _ = p /* ERROR >= not defined */ >= q + _ = p /* ERROR "< not defined" */ < q + _ = p /* ERROR "<= not defined" */ <= q + _ = p /* ERROR "> not defined" */ > q + _ = p /* ERROR ">= not defined" */ >= q // various element types type ( @@ -115,11 +115,11 @@ func pointers() { p2 P2 ) _ = ps1 == ps1 - _ = ps1 == ps2 /* ERROR mismatched types */ - _ = ps2 == ps1 /* ERROR mismatched types */ + _ = ps1 == ps2 /* ERROR "mismatched types" */ + _ = ps2 == ps1 /* ERROR "mismatched types" */ _ = p1 == p1 - _ = p1 == p2 /* ERROR mismatched types */ + _ = p1 == p2 /* ERROR "mismatched types" */ _ = p1 == ps1 } @@ -130,7 +130,7 @@ func channels() { _ = c == d _ = c != d _ = c == nil - _ = c /* ERROR < not defined */ < d + _ = c /* ERROR "< not defined" */ < d // various element types (named types) type ( @@ -147,13 +147,13 @@ func channels() { c2 C2 ) _ = c1 == c1 - _ = c1 == c1r /* ERROR mismatched types */ - _ = c1 == c1s /* ERROR mismatched types */ - _ = c1r == c1s /* ERROR mismatched types */ + _ = c1 == c1r /* ERROR "mismatched types" */ + _ = c1 == c1s /* ERROR "mismatched types" */ + _ = c1r == c1s /* ERROR "mismatched types" */ _ = c1 == c1a _ = c1a == c1 - _ = c1 == c2 /* ERROR mismatched types */ - _ = c1a == c2 /* ERROR mismatched types */ + _ = c1 == c2 /* ERROR "mismatched types" */ + _ = c1a == c2 /* ERROR "mismatched types" */ // various element types (unnamed types) var ( @@ -166,11 +166,11 @@ func channels() { _ = d1 == d1 _ = d1 == d1r _ = d1 == d1s - _ = d1r == d1s /* ERROR mismatched types */ + _ = d1r == d1s /* ERROR "mismatched types" */ _ = d1 == d1a _ = d1a == d1 - _ = d1 == d2 /* ERROR mismatched types */ - _ = d1a == d2 /* ERROR mismatched types */ + _ = d1 == d2 /* ERROR "mismatched types" */ + _ = d1a == d2 /* ERROR "mismatched types" */ } // for interfaces test @@ -188,39 +188,39 @@ func interfaces() { _ = i == j _ = i != j _ = i == nil - _ = i /* ERROR < not defined */ < j + _ = i /* ERROR "< not defined" */ < j // various interfaces var ii interface { m() int; n() } var k interface { m() float32 } _ = i == ii - _ = i == k /* ERROR mismatched types */ + _ = i == k /* ERROR "mismatched types" */ // interfaces vs values var s1 S1 var s11 S11 var s2 S2 - _ = i == 0 /* ERROR cannot convert */ - _ = i == s1 /* ERROR mismatched types */ + _ = i == 0 /* ERROR "cannot convert" */ + _ = i == s1 /* ERROR "mismatched types" */ _ = i == &s1 _ = i == &s11 - _ = i == s2 /* ERROR mismatched types */ - _ = i == & /* ERROR mismatched types */ s2 + _ = i == s2 /* ERROR "mismatched types" */ + _ = i == & /* ERROR "mismatched types" */ s2 // issue #28164 // testcase from issue - _ = interface{}(nil) == [ /* ERROR slice can only be compared to nil */ ]int(nil) + _ = interface{}(nil) == [ /* ERROR "slice can only be compared to nil" */ ]int(nil) // related cases var e interface{} var s []int var x int - _ = e == s // ERROR slice can only be compared to nil - _ = s /* ERROR slice can only be compared to nil */ == e - _ = e /* ERROR operator < not defined on interface */ < x - _ = x < e // ERROR operator < not defined on interface + _ = e == s // ERROR "slice can only be compared to nil" + _ = s /* ERROR "slice can only be compared to nil" */ == e + _ = e /* ERROR "operator < not defined on interface" */ < x + _ = x < e // ERROR "operator < not defined on interface" } func slices() { @@ -228,11 +228,11 @@ func slices() { var s []int _ = s == nil _ = s != nil - _ = s /* ERROR < not defined */ < nil + _ = s /* ERROR "< not defined" */ < nil // slices are not otherwise comparable - _ = s /* ERROR slice can only be compared to nil */ == s - _ = s /* ERROR < not defined */ < s + _ = s /* ERROR "slice can only be compared to nil" */ == s + _ = s /* ERROR "< not defined" */ < s } func maps() { @@ -240,11 +240,11 @@ func maps() { var m map[string]int _ = m == nil _ = m != nil - _ = m /* ERROR < not defined */ < nil + _ = m /* ERROR "< not defined" */ < nil // maps are not otherwise comparable - _ = m /* ERROR map can only be compared to nil */ == m - _ = m /* ERROR < not defined */ < m + _ = m /* ERROR "map can only be compared to nil" */ == m + _ = m /* ERROR "< not defined" */ < m } func funcs() { @@ -252,9 +252,9 @@ func funcs() { var f func(int) float32 _ = f == nil _ = f != nil - _ = f /* ERROR < not defined */ < nil + _ = f /* ERROR "< not defined" */ < nil // funcs are not otherwise comparable - _ = f /* ERROR func can only be compared to nil */ == f - _ = f /* ERROR < not defined */ < f + _ = f /* ERROR "func can only be compared to nil" */ == f + _ = f /* ERROR "< not defined" */ < f } diff --git a/src/internal/types/testdata/check/expr3.go b/src/internal/types/testdata/check/expr3.go index 2da59841c6..8cf9482257 100644 --- a/src/internal/types/testdata/check/expr3.go +++ b/src/internal/types/testdata/check/expr3.go @@ -209,9 +209,9 @@ func struct_literals() { _ = time.Time{} _ = time.Time{sec /* ERROR "unknown field" */ : 0} _ = time.Time{ - 0 /* ERROR implicit assignment to unexported field wall in struct literal */, - 0 /* ERROR implicit assignment */ , - nil /* ERROR implicit assignment */ , + 0 /* ERROR "implicit assignment to unexported field wall in struct literal" */, + 0 /* ERROR "implicit assignment" */ , + nil /* ERROR "implicit assignment" */ , } } diff --git a/src/internal/types/testdata/check/go1_16.go b/src/internal/types/testdata/check/go1_16.go index 81b529044c..9675b292b6 100644 --- a/src/internal/types/testdata/check/go1_16.go +++ b/src/internal/types/testdata/check/go1_16.go @@ -12,4 +12,4 @@ type Slice []byte type Array [8]byte var s Slice -var p = (*Array)(s /* ERROR requires go1.17 or later */ ) +var p = (*Array)(s /* ERROR "requires go1.17 or later" */ ) diff --git a/src/internal/types/testdata/check/go1_19.go b/src/internal/types/testdata/check/go1_19.go index f899d93733..b6cff4f465 100644 --- a/src/internal/types/testdata/check/go1_19.go +++ b/src/internal/types/testdata/check/go1_19.go @@ -12,4 +12,4 @@ type Slice []byte type Array [8]byte var s Slice -var p = (Array)(s /* ERROR requires go1.20 or later */) +var p = (Array)(s /* ERROR "requires go1.20 or later" */) diff --git a/src/internal/types/testdata/check/go1_8.go b/src/internal/types/testdata/check/go1_8.go index 99f2fd4eb2..6a7e639792 100644 --- a/src/internal/types/testdata/check/go1_8.go +++ b/src/internal/types/testdata/check/go1_8.go @@ -9,4 +9,4 @@ package p // type alias declarations -type any = /* ERROR type aliases requires go1.9 or later */ interface{} +type any = /* ERROR "type aliases requires go1.9 or later" */ interface{} diff --git a/src/internal/types/testdata/check/importC.go b/src/internal/types/testdata/check/importC.go index 807802199f..a91feb653a 100644 --- a/src/internal/types/testdata/check/importC.go +++ b/src/internal/types/testdata/check/importC.go @@ -7,9 +7,9 @@ package importC import "C" -import _ /* ERROR cannot rename import "C" */ "C" -import foo /* ERROR cannot rename import "C" */ "C" -import . /* ERROR cannot rename import "C" */ "C" +import _ /* ERROR "cannot rename import "C"" */ "C" +import foo /* ERROR "cannot rename import "C"" */ "C" +import . /* ERROR "cannot rename import "C"" */ "C" // Test cases extracted from issue #22090. diff --git a/src/internal/types/testdata/check/importdecl0/importdecl0b.go b/src/internal/types/testdata/check/importdecl0/importdecl0b.go index 904faff681..c5216a5dec 100644 --- a/src/internal/types/testdata/check/importdecl0/importdecl0b.go +++ b/src/internal/types/testdata/check/importdecl0/importdecl0b.go @@ -8,13 +8,13 @@ import "math" import m "math" import . "testing" // declares T in file scope -import . /* ERROR .unsafe. imported and not used */ "unsafe" +import . /* ERROR ".unsafe. imported and not used" */ "unsafe" import . "fmt" // declares Println in file scope import ( - "" /* ERROR invalid import path */ - "a!b" /* ERROR invalid import path */ - "abc\xffdef" /* ERROR invalid import path */ + "" /* ERROR "invalid import path" */ + "a!b" /* ERROR "invalid import path" */ + "abc\xffdef" /* ERROR "invalid import path" */ ) // using "math" in this file doesn't affect its use in other files diff --git a/src/internal/types/testdata/check/importdecl1/importdecl1b.go b/src/internal/types/testdata/check/importdecl1/importdecl1b.go index ce8b983d28..fc39863764 100644 --- a/src/internal/types/testdata/check/importdecl1/importdecl1b.go +++ b/src/internal/types/testdata/check/importdecl1/importdecl1b.go @@ -4,7 +4,7 @@ package importdecl1 -import . /* ERROR .unsafe. imported and not used */ "unsafe" +import . /* ERROR ".unsafe. imported and not used" */ "unsafe" type B interface { A diff --git a/src/internal/types/testdata/check/init0.go b/src/internal/types/testdata/check/init0.go index 5159a176d7..ee2175e2c7 100644 --- a/src/internal/types/testdata/check/init0.go +++ b/src/internal/types/testdata/check/init0.go @@ -8,50 +8,50 @@ package init0 // initialization cycles (we don't know the types) const ( - s0 /* ERROR initialization cycle: s0 refers to itself */ = s0 + s0 /* ERROR "initialization cycle: s0 refers to itself" */ = s0 - x0 /* ERROR initialization cycle for x0 */ = y0 + x0 /* ERROR "initialization cycle for x0" */ = y0 y0 = x0 a0 = b0 - b0 /* ERROR initialization cycle for b0 */ = c0 + b0 /* ERROR "initialization cycle for b0" */ = c0 c0 = d0 d0 = b0 ) var ( - s1 /* ERROR initialization cycle: s1 refers to itself */ = s1 + s1 /* ERROR "initialization cycle: s1 refers to itself" */ = s1 - x1 /* ERROR initialization cycle for x1 */ = y1 + x1 /* ERROR "initialization cycle for x1" */ = y1 y1 = x1 a1 = b1 - b1 /* ERROR initialization cycle for b1 */ = c1 + b1 /* ERROR "initialization cycle for b1" */ = c1 c1 = d1 d1 = b1 ) // initialization cycles (we know the types) const ( - s2 /* ERROR initialization cycle: s2 refers to itself */ int = s2 + s2 /* ERROR "initialization cycle: s2 refers to itself" */ int = s2 - x2 /* ERROR initialization cycle for x2 */ int = y2 + x2 /* ERROR "initialization cycle for x2" */ int = y2 y2 = x2 a2 = b2 - b2 /* ERROR initialization cycle for b2 */ int = c2 + b2 /* ERROR "initialization cycle for b2" */ int = c2 c2 = d2 d2 = b2 ) var ( - s3 /* ERROR initialization cycle: s3 refers to itself */ int = s3 + s3 /* ERROR "initialization cycle: s3 refers to itself" */ int = s3 - x3 /* ERROR initialization cycle for x3 */ int = y3 + x3 /* ERROR "initialization cycle for x3" */ int = y3 y3 = x3 a3 = b3 - b3 /* ERROR initialization cycle for b3 */ int = c3 + b3 /* ERROR "initialization cycle for b3" */ int = c3 c3 = d3 d3 = b3 ) @@ -61,25 +61,25 @@ var ( type S1 struct { f int } -const cx3 S1 /* ERROR invalid constant type */ = S1{cx3.f} -var vx3 /* ERROR initialization cycle: vx3 refers to itself */ S1 = S1{vx3.f} +const cx3 S1 /* ERROR "invalid constant type" */ = S1{cx3.f} +var vx3 /* ERROR "initialization cycle: vx3 refers to itself" */ S1 = S1{vx3.f} // cycles via functions var x4 = x5 -var x5 /* ERROR initialization cycle for x5 */ = f1() +var x5 /* ERROR "initialization cycle for x5" */ = f1() func f1() int { return x5*10 } -var x6, x7 /* ERROR initialization cycle */ = f2() +var x6, x7 /* ERROR "initialization cycle" */ = f2() var x8 = x7 func f2() (int, int) { return f3() + f3(), 0 } func f3() int { return x8 } // cycles via function literals -var x9 /* ERROR initialization cycle: x9 refers to itself */ = func() int { return x9 }() +var x9 /* ERROR "initialization cycle: x9 refers to itself" */ = func() int { return x9 }() -var x10 /* ERROR initialization cycle for x10 */ = f4() +var x10 /* ERROR "initialization cycle for x10" */ = f4() func f4() int { _ = func() { @@ -94,7 +94,7 @@ type T1 struct{} func (T1) m() bool { _ = x11; return false } -var x11 /* ERROR initialization cycle for x11 */ = T1.m(T1{}) +var x11 /* ERROR "initialization cycle for x11" */ = T1.m(T1{}) // cycles via method values @@ -103,4 +103,4 @@ type T2 struct{} func (T2) m() bool { _ = x12; return false } var t1 T2 -var x12 /* ERROR initialization cycle for x12 */ = t1.m +var x12 /* ERROR "initialization cycle for x12" */ = t1.m diff --git a/src/internal/types/testdata/check/init1.go b/src/internal/types/testdata/check/init1.go index 39ca31466b..c89032ad62 100644 --- a/src/internal/types/testdata/check/init1.go +++ b/src/internal/types/testdata/check/init1.go @@ -14,7 +14,7 @@ func (T0) m() int { return y0 } var x0 = T0{} -var y0 /* ERROR initialization cycle */ = x0.m() +var y0 /* ERROR "initialization cycle" */ = x0.m() type T1 struct{} @@ -28,7 +28,7 @@ var y1 = x1.m() // no cycle reported, x1 is of interface type // issue 6703 (modified) -var x2 /* ERROR initialization cycle */ = T2.m +var x2 /* ERROR "initialization cycle" */ = T2.m var y2 = x2 @@ -39,7 +39,7 @@ func (T2) m() int { return 0 } -var x3 /* ERROR initialization cycle */ = T3.m(T3{}) // <<<< added (T3{}) +var x3 /* ERROR "initialization cycle" */ = T3.m(T3{}) // <<<< added (T3{}) var y3 = x3 @@ -50,7 +50,7 @@ func (T3) m() int { return 0 } -var x4 /* ERROR initialization cycle */ = T4{}.m // <<<< added {} +var x4 /* ERROR "initialization cycle" */ = T4{}.m // <<<< added {} var y4 = x4 @@ -61,7 +61,7 @@ func (T4) m() int { return 0 } -var x5 /* ERROR initialization cycle */ = T5{}.m() // <<<< added () +var x5 /* ERROR "initialization cycle" */ = T5{}.m() // <<<< added () var y5 = x5 @@ -76,7 +76,7 @@ func (T5) m() int { // simplified test case var x6 = f6 -var y6 /* ERROR initialization cycle */ = f6 +var y6 /* ERROR "initialization cycle" */ = f6 func f6() { _ = y6 } // full test case @@ -92,6 +92,6 @@ func matchList(s *S) E { return matcher(matchAnyFn)(s) } var foo = matcher(matchList) -var matchAny /* ERROR initialization cycle */ = matcher(matchList) +var matchAny /* ERROR "initialization cycle" */ = matcher(matchList) func matchAnyFn(s *S) (err E) { return matchAny(s) } \ No newline at end of file diff --git a/src/internal/types/testdata/check/init2.go b/src/internal/types/testdata/check/init2.go index 614db6c949..24e9277122 100644 --- a/src/internal/types/testdata/check/init2.go +++ b/src/internal/types/testdata/check/init2.go @@ -9,131 +9,131 @@ package init2 // cycles through functions func f1() int { _ = x1; return 0 } -var x1 /* ERROR initialization cycle */ = f1 +var x1 /* ERROR "initialization cycle" */ = f1 func f2() int { _ = x2; return 0 } -var x2 /* ERROR initialization cycle */ = f2() +var x2 /* ERROR "initialization cycle" */ = f2() // cycles through method expressions type T3 int func (T3) m() int { _ = x3; return 0 } -var x3 /* ERROR initialization cycle */ = T3.m +var x3 /* ERROR "initialization cycle" */ = T3.m type T4 int func (T4) m() int { _ = x4; return 0 } -var x4 /* ERROR initialization cycle */ = T4.m(0) +var x4 /* ERROR "initialization cycle" */ = T4.m(0) type T3p int func (*T3p) m() int { _ = x3p; return 0 } -var x3p /* ERROR initialization cycle */ = (*T3p).m +var x3p /* ERROR "initialization cycle" */ = (*T3p).m type T4p int func (*T4p) m() int { _ = x4p; return 0 } -var x4p /* ERROR initialization cycle */ = (*T4p).m(nil) +var x4p /* ERROR "initialization cycle" */ = (*T4p).m(nil) // cycles through method expressions of embedded methods type T5 struct { E5 } type E5 int func (E5) m() int { _ = x5; return 0 } -var x5 /* ERROR initialization cycle */ = T5.m +var x5 /* ERROR "initialization cycle" */ = T5.m type T6 struct { E6 } type E6 int func (E6) m() int { _ = x6; return 0 } -var x6 /* ERROR initialization cycle */ = T6.m(T6{0}) +var x6 /* ERROR "initialization cycle" */ = T6.m(T6{0}) type T5p struct { E5p } type E5p int func (*E5p) m() int { _ = x5p; return 0 } -var x5p /* ERROR initialization cycle */ = (*T5p).m +var x5p /* ERROR "initialization cycle" */ = (*T5p).m type T6p struct { E6p } type E6p int func (*E6p) m() int { _ = x6p; return 0 } -var x6p /* ERROR initialization cycle */ = (*T6p).m(nil) +var x6p /* ERROR "initialization cycle" */ = (*T6p).m(nil) // cycles through method values type T7 int func (T7) m() int { _ = x7; return 0 } -var x7 /* ERROR initialization cycle */ = T7(0).m +var x7 /* ERROR "initialization cycle" */ = T7(0).m type T8 int func (T8) m() int { _ = x8; return 0 } -var x8 /* ERROR initialization cycle */ = T8(0).m() +var x8 /* ERROR "initialization cycle" */ = T8(0).m() type T7p int func (*T7p) m() int { _ = x7p; return 0 } -var x7p /* ERROR initialization cycle */ = new(T7p).m +var x7p /* ERROR "initialization cycle" */ = new(T7p).m type T8p int func (*T8p) m() int { _ = x8p; return 0 } -var x8p /* ERROR initialization cycle */ = new(T8p).m() +var x8p /* ERROR "initialization cycle" */ = new(T8p).m() type T7v int func (T7v) m() int { _ = x7v; return 0 } var x7var T7v -var x7v /* ERROR initialization cycle */ = x7var.m +var x7v /* ERROR "initialization cycle" */ = x7var.m type T8v int func (T8v) m() int { _ = x8v; return 0 } var x8var T8v -var x8v /* ERROR initialization cycle */ = x8var.m() +var x8v /* ERROR "initialization cycle" */ = x8var.m() type T7pv int func (*T7pv) m() int { _ = x7pv; return 0 } var x7pvar *T7pv -var x7pv /* ERROR initialization cycle */ = x7pvar.m +var x7pv /* ERROR "initialization cycle" */ = x7pvar.m type T8pv int func (*T8pv) m() int { _ = x8pv; return 0 } var x8pvar *T8pv -var x8pv /* ERROR initialization cycle */ = x8pvar.m() +var x8pv /* ERROR "initialization cycle" */ = x8pvar.m() // cycles through method values of embedded methods type T9 struct { E9 } type E9 int func (E9) m() int { _ = x9; return 0 } -var x9 /* ERROR initialization cycle */ = T9{0}.m +var x9 /* ERROR "initialization cycle" */ = T9{0}.m type T10 struct { E10 } type E10 int func (E10) m() int { _ = x10; return 0 } -var x10 /* ERROR initialization cycle */ = T10{0}.m() +var x10 /* ERROR "initialization cycle" */ = T10{0}.m() type T9p struct { E9p } type E9p int func (*E9p) m() int { _ = x9p; return 0 } -var x9p /* ERROR initialization cycle */ = new(T9p).m +var x9p /* ERROR "initialization cycle" */ = new(T9p).m type T10p struct { E10p } type E10p int func (*E10p) m() int { _ = x10p; return 0 } -var x10p /* ERROR initialization cycle */ = new(T10p).m() +var x10p /* ERROR "initialization cycle" */ = new(T10p).m() type T9v struct { E9v } type E9v int func (E9v) m() int { _ = x9v; return 0 } var x9var T9v -var x9v /* ERROR initialization cycle */ = x9var.m +var x9v /* ERROR "initialization cycle" */ = x9var.m type T10v struct { E10v } type E10v int func (E10v) m() int { _ = x10v; return 0 } var x10var T10v -var x10v /* ERROR initialization cycle */ = x10var.m() +var x10v /* ERROR "initialization cycle" */ = x10var.m() type T9pv struct { E9pv } type E9pv int func (*E9pv) m() int { _ = x9pv; return 0 } var x9pvar *T9pv -var x9pv /* ERROR initialization cycle */ = x9pvar.m +var x9pv /* ERROR "initialization cycle" */ = x9pvar.m type T10pv struct { E10pv } type E10pv int func (*E10pv) m() int { _ = x10pv; return 0 } var x10pvar *T10pv -var x10pv /* ERROR initialization cycle */ = x10pvar.m() +var x10pv /* ERROR "initialization cycle" */ = x10pvar.m() diff --git a/src/internal/types/testdata/check/issues0.go b/src/internal/types/testdata/check/issues0.go index 4a66641369..c8c92ba1ef 100644 --- a/src/internal/types/testdata/check/issues0.go +++ b/src/internal/types/testdata/check/issues0.go @@ -25,25 +25,25 @@ func issue7035() { func issue8066() { const ( _ = float32(340282356779733661637539395458142568447) - _ = float32(340282356779733661637539395458142568448 /* ERROR cannot convert */ ) + _ = float32(340282356779733661637539395458142568448 /* ERROR "cannot convert" */ ) ) } // Check that a missing identifier doesn't lead to a spurious error cascade. func issue8799a() { - x, ok := missing /* ERROR undefined */ () + x, ok := missing /* ERROR "undefined" */ () _ = !ok _ = x } func issue8799b(x int, ok bool) { - x, ok = missing /* ERROR undefined */ () + x, ok = missing /* ERROR "undefined" */ () _ = !ok _ = x } func issue9182() { - type Point C /* ERROR undefined */ .Point + type Point C /* ERROR "undefined" */ .Point // no error for composite literal based on unknown type _ = Point{x: 1, y: 2} } @@ -59,54 +59,54 @@ func issue9473(a []int, b ...int) { _ = append(f0()) _ = append(f0(), f0()...) _ = append(f1()) - _ = append(f2 /* ERROR cannot use .* in argument */ ()) - _ = append(f2()... /* ERROR cannot use ... */ ) - _ = append(f0(), f1 /* ERROR multiple-value f1 */ ()) - _ = append(f0(), f2 /* ERROR multiple-value f2 */ ()) - _ = append(f0(), f1 /* ERROR multiple-value f1 */ ()...) - _ = append(f0(), f2 /* ERROR multiple-value f2 */ ()...) + _ = append(f2 /* ERROR "cannot use .* in argument" */ ()) + _ = append(f2()... /* ERROR "cannot use ..." */ ) + _ = append(f0(), f1 /* ERROR "multiple-value f1" */ ()) + _ = append(f0(), f2 /* ERROR "multiple-value f2" */ ()) + _ = append(f0(), f1 /* ERROR "multiple-value f1" */ ()...) + _ = append(f0(), f2 /* ERROR "multiple-value f2" */ ()...) // variadic user-defined function append_(f0()) append_(f0(), f0()...) append_(f1()) - append_(f2 /* ERROR cannot use .* in argument */ ()) - append_(f2()... /* ERROR cannot use ... */ ) - append_(f0(), f1 /* ERROR multiple-value f1 */ ()) - append_(f0(), f2 /* ERROR multiple-value f2 */ ()) - append_(f0(), f1 /* ERROR multiple-value f1 */ ()...) - append_(f0(), f2 /* ERROR multiple-value f2 */ ()...) + append_(f2 /* ERROR "cannot use .* in argument" */ ()) + append_(f2()... /* ERROR "cannot use ..." */ ) + append_(f0(), f1 /* ERROR "multiple-value f1" */ ()) + append_(f0(), f2 /* ERROR "multiple-value f2" */ ()) + append_(f0(), f1 /* ERROR "multiple-value f1" */ ()...) + append_(f0(), f2 /* ERROR "multiple-value f2" */ ()...) } // Check that embedding a non-interface type in an interface results in a good error message. func issue10979() { type _ interface { - int /* ERROR non-interface type int */ + int /* ERROR "non-interface type int" */ } type T struct{} type _ interface { - T /* ERROR non-interface type T */ + T /* ERROR "non-interface type T" */ } type _ interface { - nosuchtype /* ERROR undefined: nosuchtype */ + nosuchtype /* ERROR "undefined: nosuchtype" */ } type _ interface { - fmt.Nosuchtype /* ERROR undefined: fmt\.Nosuchtype */ + fmt.Nosuchtype /* ERROR "undefined: fmt\.Nosuchtype" */ } type _ interface { - nosuchpkg /* ERROR undefined: nosuchpkg */ .Nosuchtype + nosuchpkg /* ERROR "undefined: nosuchpkg" */ .Nosuchtype } type I interface { - I.m /* ERROR I.m is not a type */ + I.m /* ERROR "I.m is not a type" */ m() } } // issue11347 // These should not crash. -var a1, b1 /* ERROR cycle */ , c1 /* ERROR cycle */ b1 = 0 > 0<<""[""[c1]]>c1 -var a2, b2 /* ERROR cycle */ = 0 /* ERROR assignment mismatch */ /* ERROR assignment mismatch */ > 0<<""[b2] -var a3, b3 /* ERROR cycle */ = int /* ERROR assignment mismatch */ /* ERROR assignment mismatch */ (1<<""[b3]) +var a1, b1 /* ERROR "cycle" */ , c1 /* ERROR "cycle" */ b1 = 0 > 0<<""[""[c1]]>c1 +var a2, b2 /* ERROR "cycle" */ = 0 /* ERROR "assignment mismatch" */ /* ERROR "assignment mismatch" */ > 0<<""[b2] +var a3, b3 /* ERROR "cycle" */ = int /* ERROR "assignment mismatch" */ /* ERROR "assignment mismatch" */ (1<<""[b3]) // issue10260 // Check that error messages explain reason for interface assignment failures. @@ -133,42 +133,42 @@ func issue10260() { ) var x I1 - x = T1 /* ERROR cannot use T1{} .* as I1 value in assignment: T1 does not implement I1 \(method foo has pointer receiver\) */ {} - _ = x /* ERROR impossible type assertion: x\.\(T1\)\n\tT1 does not implement I1 \(method foo has pointer receiver\) */ .(T1) + x = T1 /* ERROR "cannot use T1{} .* as I1 value in assignment: T1 does not implement I1 \(method foo has pointer receiver\)" */ {} + _ = x /* ERROR "impossible type assertion: x\.\(T1\)\n\tT1 does not implement I1 \(method foo has pointer receiver\)" */ .(T1) - T1{}.foo /* ERROR cannot call pointer method foo on T1 */ () + T1{}.foo /* ERROR "cannot call pointer method foo on T1" */ () x.Foo /* ERROR "x.Foo undefined \(type I1 has no field or method Foo, but does have foo\)" */ () - _ = i2 /* ERROR impossible type assertion: i2\.\(\*T1\)\n\t\*T1 does not implement I2 \(wrong type for method foo\)\n\t\thave foo\(\)\n\t\twant foo\(int\) */ .(*T1) + _ = i2 /* ERROR "impossible type assertion: i2\.\(\*T1\)\n\t\*T1 does not implement I2 \(wrong type for method foo\)\n\t\thave foo\(\)\n\t\twant foo\(int\)" */ .(*T1) - i1 = i0 /* ERROR cannot use i0 .* as I1 value in assignment: I0 does not implement I1 \(missing method foo\) */ - i1 = t0 /* ERROR .* t0 .* as I1 .*: \*T0 does not implement I1 \(missing method foo\) */ - i1 = i2 /* ERROR .* i2 .* as I1 .*: I2 does not implement I1 \(wrong type for method foo\)\n\t\thave foo\(int\)\n\t\twant foo\(\) */ - i1 = t2 /* ERROR .* t2 .* as I1 .*: \*T2 does not implement I1 \(wrong type for method foo\)\n\t\thave foo\(int\)\n\t\twant foo\(\) */ - i2 = i1 /* ERROR .* i1 .* as I2 .*: I1 does not implement I2 \(wrong type for method foo\)\n\t\thave foo\(\)\n\t\twant foo\(int\) */ - i2 = t1 /* ERROR .* t1 .* as I2 .*: \*T1 does not implement I2 \(wrong type for method foo\)\n\t\thave foo\(\)\n\t\twant foo\(int\) */ + i1 = i0 /* ERROR "cannot use i0 .* as I1 value in assignment: I0 does not implement I1 \(missing method foo\)" */ + i1 = t0 /* ERROR ".* t0 .* as I1 .*: \*T0 does not implement I1 \(missing method foo\)" */ + i1 = i2 /* ERROR ".* i2 .* as I1 .*: I2 does not implement I1 \(wrong type for method foo\)\n\t\thave foo\(int\)\n\t\twant foo\(\)" */ + i1 = t2 /* ERROR ".* t2 .* as I1 .*: \*T2 does not implement I1 \(wrong type for method foo\)\n\t\thave foo\(int\)\n\t\twant foo\(\)" */ + i2 = i1 /* ERROR ".* i1 .* as I2 .*: I1 does not implement I2 \(wrong type for method foo\)\n\t\thave foo\(\)\n\t\twant foo\(int\)" */ + i2 = t1 /* ERROR ".* t1 .* as I2 .*: \*T1 does not implement I2 \(wrong type for method foo\)\n\t\thave foo\(\)\n\t\twant foo\(int\)" */ - _ = func() I1 { return i0 /* ERROR cannot use i0 .* as I1 value in return statement: I0 does not implement I1 \(missing method foo\) */ } - _ = func() I1 { return t0 /* ERROR .* t0 .* as I1 .*: \*T0 does not implement I1 \(missing method foo\) */ } - _ = func() I1 { return i2 /* ERROR .* i2 .* as I1 .*: I2 does not implement I1 \(wrong type for method foo\)\n\t\thave foo\(int\)\n\t\twant foo\(\) */ } - _ = func() I1 { return t2 /* ERROR .* t2 .* as I1 .*: \*T2 does not implement I1 \(wrong type for method foo\)\n\t\thave foo\(int\)\n\t\twant foo\(\) */ } - _ = func() I2 { return i1 /* ERROR .* i1 .* as I2 .*: I1 does not implement I2 \(wrong type for method foo\)\n\t\thave foo\(\)\n\t\twant foo\(int\) */ } - _ = func() I2 { return t1 /* ERROR .* t1 .* as I2 .*: \*T1 does not implement I2 \(wrong type for method foo\)\n\t\thave foo\(\)\n\t\twant foo\(int\) */ } + _ = func() I1 { return i0 /* ERROR "cannot use i0 .* as I1 value in return statement: I0 does not implement I1 \(missing method foo\)" */ } + _ = func() I1 { return t0 /* ERROR ".* t0 .* as I1 .*: \*T0 does not implement I1 \(missing method foo\)" */ } + _ = func() I1 { return i2 /* ERROR ".* i2 .* as I1 .*: I2 does not implement I1 \(wrong type for method foo\)\n\t\thave foo\(int\)\n\t\twant foo\(\)" */ } + _ = func() I1 { return t2 /* ERROR ".* t2 .* as I1 .*: \*T2 does not implement I1 \(wrong type for method foo\)\n\t\thave foo\(int\)\n\t\twant foo\(\)" */ } + _ = func() I2 { return i1 /* ERROR ".* i1 .* as I2 .*: I1 does not implement I2 \(wrong type for method foo\)\n\t\thave foo\(\)\n\t\twant foo\(int\)" */ } + _ = func() I2 { return t1 /* ERROR ".* t1 .* as I2 .*: \*T1 does not implement I2 \(wrong type for method foo\)\n\t\thave foo\(\)\n\t\twant foo\(int\)" */ } // a few more - less exhaustive now f := func(I1, I2){} - f(i0 /* ERROR missing method foo */ , i1 /* ERROR wrong type for method foo */ ) + f(i0 /* ERROR "missing method foo" */ , i1 /* ERROR "wrong type for method foo" */ ) - _ = [...]I1{i0 /* ERROR cannot use i0 .* as I1 value in array or slice literal: I0 does not implement I1 \(missing method foo\) */ } - _ = [...]I1{i2 /* ERROR cannot use i2 .* as I1 value in array or slice literal: I2 does not implement I1 \(wrong type for method foo\)\n\t\thave foo\(int\)\n\t\twant foo\(\) */ } - _ = []I1{i0 /* ERROR missing method foo */ } - _ = []I1{i2 /* ERROR wrong type for method foo */ } - _ = map[int]I1{0: i0 /* ERROR missing method foo */ } - _ = map[int]I1{0: i2 /* ERROR wrong type for method foo */ } + _ = [...]I1{i0 /* ERROR "cannot use i0 .* as I1 value in array or slice literal: I0 does not implement I1 \(missing method foo\)" */ } + _ = [...]I1{i2 /* ERROR "cannot use i2 .* as I1 value in array or slice literal: I2 does not implement I1 \(wrong type for method foo\)\n\t\thave foo\(int\)\n\t\twant foo\(\)" */ } + _ = []I1{i0 /* ERROR "missing method foo" */ } + _ = []I1{i2 /* ERROR "wrong type for method foo" */ } + _ = map[int]I1{0: i0 /* ERROR "missing method foo" */ } + _ = map[int]I1{0: i2 /* ERROR "wrong type for method foo" */ } - make(chan I1) <- i0 /* ERROR missing method foo */ - make(chan I1) <- i2 /* ERROR wrong type for method foo */ + make(chan I1) <- i0 /* ERROR "missing method foo" */ + make(chan I1) <- i2 /* ERROR "wrong type for method foo" */ } // Check that constants representable as integers are in integer form @@ -199,7 +199,7 @@ func issue15755() { _ = x == y // related: we should see an error since the result of f1 is ([]int, int) - var u, v []int = f1 /* ERROR cannot use f1 */ () + var u, v []int = f1 /* ERROR "cannot use f1" */ () _ = u _ = v } @@ -240,7 +240,7 @@ func issue24026() { // b and c must not be visible inside function literal a := 0 a, b, c := func() (int, int, int) { - return a, b /* ERROR undefined */ , c /* ERROR undefined */ + return a, b /* ERROR "undefined" */ , c /* ERROR "undefined" */ }() _, _ = b, c } @@ -260,10 +260,10 @@ func issue24140(x interface{}) int { // Test that we don't crash when the 'if' condition is missing. func issue25438() { - if { /* ERROR missing condition */ } - if x := 0; /* ERROR missing condition */ { _ = x } + if { /* ERROR "missing condition" */ } + if x := 0; /* ERROR "missing condition" */ { _ = x } if - { /* ERROR missing condition */ } + { /* ERROR "missing condition" */ } } // Test that we can embed alias type names in interfaces. @@ -277,12 +277,12 @@ type E = interface { // Test case from issue. // cmd/compile reports a cycle as well. -type issue25301b /* ERROR invalid recursive type */ = interface { +type issue25301b /* ERROR "invalid recursive type" */ = interface { m() interface{ issue25301b } } type issue25301c interface { - notE // ERROR non-interface type struct\{\} + notE // ERROR "non-interface type struct\{\}" } type notE = struct{} @@ -313,28 +313,28 @@ type allocator struct { // Test that we don't crash when type-checking composite literals // containing errors in the type. -var issue27346 = [][n /* ERROR undefined */ ]int{ +var issue27346 = [][n /* ERROR "undefined" */ ]int{ 0: {}, } -var issue22467 = map[int][... /* ERROR invalid use of ... */ ]int{0: {}} +var issue22467 = map[int][... /* ERROR "invalid use of ..." */ ]int{0: {}} // Test that invalid use of ... in parameter lists is recognized // (issue #28281). func issue28281a(int, int, ...int) func issue28281b(a, b int, c ...int) -func issue28281c(a, b, c ... /* ERROR can only use ... with final parameter */ int) -func issue28281d(... /* ERROR can only use ... with final parameter */ int, int) -func issue28281e(a, b, c ... /* ERROR can only use ... with final parameter */ int, d int) -func issue28281f(... /* ERROR can only use ... with final parameter */ int, ... /* ERROR can only use ... with final parameter */ int, int) -func (... /* ERROR can only use ... with final parameter */ TT) f() -func issue28281g() (... /* ERROR can only use ... with final parameter */ TT) +func issue28281c(a, b, c ... /* ERROR "can only use ... with final parameter" */ int) +func issue28281d(... /* ERROR "can only use ... with final parameter" */ int, int) +func issue28281e(a, b, c ... /* ERROR "can only use ... with final parameter" */ int, d int) +func issue28281f(... /* ERROR "can only use ... with final parameter" */ int, ... /* ERROR "can only use ... with final parameter" */ int, int) +func (... /* ERROR "can only use ... with final parameter" */ TT) f() +func issue28281g() (... /* ERROR "can only use ... with final parameter" */ TT) // Issue #26234: Make various field/method lookup errors easier to read by matching cmd/compile's output func issue26234a(f *syn.Prog) { // The error message below should refer to the actual package name (syntax) // not the local package name (syn). - f.foo /* ERROR f\.foo undefined \(type \*syntax\.Prog has no field or method foo\) */ + f.foo /* ERROR "f\.foo undefined \(type \*syntax\.Prog has no field or method foo\)" */ } type T struct { @@ -347,23 +347,23 @@ type E1 struct{ f int } type E2 struct{ f int } func issue26234b(x T) { - _ = x.f /* ERROR ambiguous selector x.f */ + _ = x.f /* ERROR "ambiguous selector x.f" */ } func issue26234c() { - T.x /* ERROR T.x undefined \(type T has no method x\) */ () + T.x /* ERROR "T.x undefined \(type T has no method x\)" */ () } func issue35895() { // T is defined in this package, don't qualify its name with the package name. - var _ T = 0 // ERROR cannot use 0 \(untyped int constant\) as T + var _ T = 0 // ERROR "cannot use 0 \(untyped int constant\) as T" // There is only one package with name syntax imported, only use the (global) package name in error messages. - var _ *syn.Prog = 0 // ERROR cannot use 0 \(untyped int constant\) as \*syntax.Prog + var _ *syn.Prog = 0 // ERROR "cannot use 0 \(untyped int constant\) as \*syntax.Prog" // Because both t1 and t2 have the same global package name (template), // qualify packages with full path name in this case. - var _ t1.Template = t2 /* ERROR cannot use .* \(value of type .html/template.\.Template\) as .text/template.\.Template */ .Template{} + var _ t1.Template = t2 /* ERROR "cannot use .* \(value of type .html/template.\.Template\) as .text/template.\.Template" */ .Template{} } func issue42989(s uint) { diff --git a/src/internal/types/testdata/check/issues1.go b/src/internal/types/testdata/check/issues1.go index 2f3414de61..efde922cd2 100644 --- a/src/internal/types/testdata/check/issues1.go +++ b/src/internal/types/testdata/check/issues1.go @@ -18,11 +18,11 @@ func eql[T comparable](x, y T) bool { func _[X comparable, Y interface{comparable; m()}]() { var x X var y Y - eql(x, y /* ERROR does not match */ ) // interfaces of different types + eql(x, y /* ERROR "does not match" */ ) // interfaces of different types eql(x, x) eql(y, y) - eql(y, nil /* ERROR cannot use nil as Y value in argument to eql */ ) - eql[io /* ERROR does not satisfy comparable */ .Reader](nil, nil) + eql(y, nil /* ERROR "cannot use nil as Y value in argument to eql" */ ) + eql[io /* ERROR "does not satisfy comparable" */ .Reader](nil, nil) } // If we have a receiver of pointer to type parameter type (below: *T) @@ -33,12 +33,12 @@ type C[T any] interface { // using type bound C func _[T C[T]](x *T) { - x.m /* ERROR x\.m undefined */ () + x.m /* ERROR "x\.m undefined" */ () } // using an interface literal as bound func _[T interface{ m() }](x *T) { - x.m /* ERROR x\.m undefined */ () + x.m /* ERROR "x\.m undefined" */ () } func f2[_ interface{ m1(); m2() }]() {} @@ -48,7 +48,7 @@ func (T) m1() func (*T) m2() func _() { - f2[T /* ERROR m2 has pointer receiver */ ]() + f2[T /* ERROR "m2 has pointer receiver" */ ]() f2[*T]() } @@ -58,7 +58,7 @@ func _() { type T1[P interface{~uint}] struct{} func _[P any]() { - _ = T1[P /* ERROR P does not satisfy interface{~uint} */ ]{} + _ = T1[P /* ERROR "P does not satisfy interface{~uint}" */ ]{} } // This is the original (simplified) program causing the same issue. @@ -74,8 +74,8 @@ func (u T2[U]) Add1() U { return u.s + 1 } -func NewT2[U any]() T2[U /* ERROR U does not satisfy Unsigned */ ] { - return T2[U /* ERROR U does not satisfy Unsigned */ ]{} +func NewT2[U any]() T2[U /* ERROR "U does not satisfy Unsigned" */ ] { + return T2[U /* ERROR "U does not satisfy Unsigned" */ ]{} } func _() { @@ -145,8 +145,8 @@ type List3[TElem any] struct { } // Infinite generic type declarations must lead to an error. -type inf1[T any] struct{ _ inf1 /* ERROR invalid recursive type */ [T] } -type inf2[T any] struct{ inf2 /* ERROR invalid recursive type */ [T] } +type inf1[T any] struct{ _ inf1 /* ERROR "invalid recursive type" */ [T] } +type inf2[T any] struct{ inf2 /* ERROR "invalid recursive type" */ [T] } // The implementation of conversions T(x) between integers and floating-point // numbers checks that both T and x have either integer or floating-point @@ -201,7 +201,7 @@ func _[T interface{~int}](x T) { // (Example by mdempsky@.) func _[T interface { ~[10]int }](x T) { _ = x[9] // ok - _ = x[20 /* ERROR out of bounds */ ] + _ = x[20 /* ERROR "out of bounds" */ ] } // Pointer indirection of a type parameter. @@ -248,5 +248,5 @@ var _ = append[context.CancelFunc, []context.CancelFunc, context.CancelFunc](can func g[T any](T) T { panic(0) } var _ = g[int] -var _ = g[nil /* ERROR is not a type */ ] +var _ = g[nil /* ERROR "is not a type" */ ] var _ = g(0) diff --git a/src/internal/types/testdata/check/main0.go b/src/internal/types/testdata/check/main0.go index 132a5fec45..95a8ed1d6d 100644 --- a/src/internal/types/testdata/check/main0.go +++ b/src/internal/types/testdata/check/main0.go @@ -5,5 +5,5 @@ package main func main() -func main /* ERROR "no arguments and no return values" */ /* ERROR redeclared */ (int) -func main /* ERROR "no arguments and no return values" */ /* ERROR redeclared */ () int +func main /* ERROR "no arguments and no return values" */ /* ERROR "redeclared" */ (int) +func main /* ERROR "no arguments and no return values" */ /* ERROR "redeclared" */ () int diff --git a/src/internal/types/testdata/check/map0.go b/src/internal/types/testdata/check/map0.go index 814d9539fd..21c989cc9d 100644 --- a/src/internal/types/testdata/check/map0.go +++ b/src/internal/types/testdata/check/map0.go @@ -6,7 +6,7 @@ package orderedmap // TODO(gri) fix imports for tests -import "chans" // ERROR could not import +import "chans" // ERROR "could not import" // Map is an ordered map. type Map[K, V any] struct { diff --git a/src/internal/types/testdata/check/methodsets.go b/src/internal/types/testdata/check/methodsets.go index d145bc09f5..27f6d31f88 100644 --- a/src/internal/types/testdata/check/methodsets.go +++ b/src/internal/types/testdata/check/methodsets.go @@ -29,7 +29,7 @@ type T3 struct { func _() { var ( _ func(T0) = T0.v0 - _ = T0.p0 /* ERROR invalid method expression T0\.p0 \(needs pointer receiver \(\*T0\)\.p0\) */ + _ = T0.p0 /* ERROR "invalid method expression T0\.p0 \(needs pointer receiver \(\*T0\)\.p0\)" */ _ func (*T0) = (*T0).v0 _ func (*T0) = (*T0).p0 @@ -40,7 +40,7 @@ func _() { _ func(T2) = T2.p2 _ func(T3) = T3.v0 - _ func(T3) = T3.p0 /* ERROR invalid method expression T3\.p0 \(needs pointer receiver \(\*T3\)\.p0\) */ + _ func(T3) = T3.p0 /* ERROR "invalid method expression T3\.p0 \(needs pointer receiver \(\*T3\)\.p0\)" */ _ func(T3) = T3.v1 _ func(T3) = T3.p1 _ func(T3) = T3.v2 diff --git a/src/internal/types/testdata/check/shifts.go b/src/internal/types/testdata/check/shifts.go index 5cd0182d52..a9a3e34725 100644 --- a/src/internal/types/testdata/check/shifts.go +++ b/src/internal/types/testdata/check/shifts.go @@ -206,7 +206,7 @@ func shifts6() { // _ = int(1.0<