test: match gofrontend error messages

fixedbugs/issue20602.go:13:9: error: argument must have complex type
fixedbugs/issue20602.go:14:9: error: argument must have complex type

fixedbugs/issue19323.go:12:12: error: attempt to slice object that is not array, slice, or string
fixedbugs/issue19323.go:18:13: error: attempt to slice object that is not array, slice, or string

fixedbugs/issue20749.go:12:11: error: array index out of bounds
fixedbugs/issue20749.go:15:11: error: array index out of bounds

fixedbugs/issue20415.go:14:5: error: redefinition of ‘f’
fixedbugs/issue20415.go:12:5: note: previous definition of ‘f’ was here
fixedbugs/issue20415.go:25:5: error: redefinition of ‘g’
fixedbugs/issue20415.go:20:5: note: previous definition of ‘g’ was here
fixedbugs/issue20415.go:33:5: error: redefinition of ‘h’
fixedbugs/issue20415.go:31:5: note: previous definition of ‘h’ was here

fixedbugs/issue19977.go:12:21: error: reference to undefined name ‘a’

fixedbugs/issue20812.go:10:13: error: invalid type conversion (cannot use type string as type int)
fixedbugs/issue20812.go:11:13: error: invalid type conversion (cannot use type int as type bool)
fixedbugs/issue20812.go:12:13: error: invalid type conversion (cannot use type string as type bool)
fixedbugs/issue20812.go:13:13: error: invalid type conversion (cannot use type bool as type int)
fixedbugs/issue20812.go:14:13: error: invalid type conversion (cannot use type bool as type string)

fixedbugs/issue21256.go:9:5: error: redefinition of ‘main’

fixedbugs/issue20813.go:10:11: error: invalid left hand side of assignment

fixedbugs/issue20185.go:22:16: error: ‘t’ declared but not used
fixedbugs/issue20185.go:13:9: error: cannot type switch on non-interface value
fixedbugs/issue20185.go:22:9: error: cannot type switch on non-interface value

fixedbugs/issue20227.go:11:11: error: division by zero
fixedbugs/issue20227.go:12:12: error: division by zero
fixedbugs/issue20227.go:13:12: error: division by zero
fixedbugs/issue20227.go:15:11: error: division by zero
fixedbugs/issue20227.go:16:12: error: division by zero

fixedbugs/issue19880.go:14:13: error: invalid use of type

fixedbugs/issue23093.go:9:5: error: initialization expression for ‘f’ depends upon itself

fixedbugs/issue21979.go:29:13: error: integer constant overflow
fixedbugs/issue21979.go:39:13: error: complex constant truncated to floating-point
fixedbugs/issue21979.go:10:13: error: invalid type conversion (cannot use type string as type bool)
fixedbugs/issue21979.go:11:13: error: invalid type conversion (cannot use type int as type bool)
fixedbugs/issue21979.go:12:13: error: invalid type conversion (cannot use type float64 as type bool)
fixedbugs/issue21979.go:13:13: error: invalid type conversion (cannot use type complex128 as type bool)
fixedbugs/issue21979.go:15:13: error: invalid type conversion (cannot use type bool as type string)
fixedbugs/issue21979.go:17:13: error: invalid type conversion (cannot use type float64 as type string)
fixedbugs/issue21979.go:18:13: error: invalid type conversion (cannot use type complex128 as type string)
fixedbugs/issue21979.go:20:13: error: invalid type conversion (cannot use type string as type int)
fixedbugs/issue21979.go:21:13: error: invalid type conversion (cannot use type bool as type int)
fixedbugs/issue21979.go:27:13: error: invalid type conversion (cannot use type string as type uint)
fixedbugs/issue21979.go:28:13: error: invalid type conversion (cannot use type bool as type uint)
fixedbugs/issue21979.go:34:13: error: invalid type conversion (cannot use type string as type float64)
fixedbugs/issue21979.go:35:13: error: invalid type conversion (cannot use type bool as type float64)
fixedbugs/issue21979.go:41:13: error: invalid type conversion (cannot use type string as type complex128)
fixedbugs/issue21979.go:42:13: error: invalid type conversion (cannot use type bool as type complex128)

fixedbugs/issue21988.go:11:11: error: reference to undefined name ‘Wrong’

fixedbugs/issue22063.go:11:11: error: reference to undefined name ‘Wrong’

fixedbugs/issue22904.go:12:6: error: invalid recursive type ‘a’
fixedbugs/issue22904.go:13:6: error: invalid recursive type ‘b’

fixedbugs/issue22921.go:11:16: error: reference to undefined identifier ‘bytes.nonexist’
fixedbugs/issue22921.go:13:19: error: reference to undefined identifier ‘bytes.nonexist’
fixedbugs/issue22921.go:13:19: error: expected signature or type name
fixedbugs/issue22921.go:17:15: error: reference to undefined identifier ‘bytes.buffer’

fixedbugs/issue23823.go:15:9: error: invalid recursive interface
fixedbugs/issue23823.go:10:9: error: invalid recursive interface

fixedbugs/issue23732.go:24:13: error: too few expressions for struct
fixedbugs/issue23732.go:34:17: error: too many expressions for struct
fixedbugs/issue23732.go:37:13: error: too few expressions for struct
fixedbugs/issue23732.go:40:17: error: too many expressions for struct

fixedbugs/issue22794.go:16:14: error: reference to undefined field or method ‘floats’
fixedbugs/issue22794.go:18:19: error: unknown field ‘floats’ in ‘it’
fixedbugs/issue22794.go:19:17: error: unknown field ‘InneR’ in ‘it’
fixedbugs/issue22794.go:18:9: error: ‘i2’ declared but not used

fixedbugs/issue22822.go:15:17: error: expected function

fixedbugs/issue25727.go:12:10: error: reference to unexported field or method ‘doneChan’
fixedbugs/issue25727.go:13:10: error: reference to undefined field or method ‘DoneChan’
fixedbugs/issue25727.go:14:21: error: unknown field ‘tlsConfig’ in ‘http.Server’
fixedbugs/issue25727.go:15:21: error: unknown field ‘DoneChan’ in ‘http.Server’
fixedbugs/issue25727.go:21:14: error: unknown field ‘bAr’ in ‘foo’

Change-Id: I32ce0b7d80017b2367b8fb479a881632240d4161
Reviewed-on: https://go-review.googlesource.com/c/go/+/277455
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
Ian Lance Taylor 2020-12-13 22:48:02 -08:00
parent ce61ccca8f
commit be10af7c4e
29 changed files with 77 additions and 77 deletions

View File

@ -9,11 +9,11 @@ package p
func g() {}
func f() {
g()[:] // ERROR "g.. used as value"
g()[:] // ERROR "g.. used as value|attempt to slice object that is not"
}
func g2() ([]byte, []byte) { return nil, nil }
func f2() {
g2()[:] // ERROR "multiple-value g2.. in single-value context"
g2()[:] // ERROR "multiple-value g2.. in single-value context|attempt to slice object that is not"
}

View File

@ -11,7 +11,7 @@ type T struct {
}
func a() {
_ = T // ERROR "type T is not an expression"
_ = T // ERROR "type T is not an expression|invalid use of type"
}
func b() {

View File

@ -9,7 +9,7 @@
package foo
func Foo() {
switch x := a.(type) { // ERROR "undefined: a"
switch x := a.(type) { // ERROR "undefined: a|reference to undefined name .*a"
default:
_ = x
}

View File

@ -10,7 +10,7 @@
package p
func F() {
switch t := nil.(type) { // ERROR "cannot type switch on non-interface value nil"
switch t := nil.(type) { // ERROR "cannot type switch on non-interface value"
default:
_ = t
}
@ -19,7 +19,7 @@ func F() {
const x = 1
func G() {
switch t := x.(type) { // ERROR "cannot type switch on non-interface value x \(type untyped int\)"
switch t := x.(type) { // ERROR "cannot type switch on non-interface value|declared but not used"
default:
}
}

View File

@ -8,9 +8,9 @@
package p
var _ = 1 / 1e-600000000i // ERROR "complex division by zero"
var _ = 1i / 1e-600000000 // ERROR "complex division by zero"
var _ = 1i / 1e-600000000i // ERROR "complex division by zero"
var _ = 1 / 1e-600000000i // ERROR "division by zero"
var _ = 1i / 1e-600000000 // ERROR "division by zero"
var _ = 1i / 1e-600000000i // ERROR "division by zero"
var _ = 1 / (1e-600000000 + 1e-600000000i) // ERROR "complex division by zero"
var _ = 1i / (1e-600000000 + 1e-600000000i) // ERROR "complex division by zero"
var _ = 1 / (1e-600000000 + 1e-600000000i) // ERROR "division by zero"
var _ = 1i / (1e-600000000 + 1e-600000000i) // ERROR "division by zero"

View File

@ -11,7 +11,7 @@ package p
// 1
var f byte
var f interface{} // ERROR "previous declaration at issue20415.go:12"
var f interface{} // ERROR "previous declaration at issue20415.go:12|redefinition"
func _(f int) {
}
@ -22,7 +22,7 @@ var g byte
func _(g int) {
}
var g interface{} // ERROR "previous declaration at issue20415.go:20"
var g interface{} // ERROR "previous declaration at issue20415.go:20|redefinition"
// 3
func _(h int) {
@ -30,4 +30,4 @@ func _(h int) {
var h byte
var h interface{} // ERROR "previous declaration at issue20415.go:31"
var h interface{} // ERROR "previous declaration at issue20415.go:31|redefinition"

View File

@ -15,7 +15,7 @@ package p
import "runtime"
func f() { // ERROR "stack frame too large"
func f() { // GC_ERROR "stack frame too large"
x := [][]int{1e9: []int{}}
runtime.KeepAlive(x)
}

View File

@ -10,5 +10,5 @@
package p
var p = &[1]complex128{0}
var _ = real(p) // ERROR "type \*\[1\]complex128"
var _ = imag(p) // ERROR "type \*\[1\]complex128"
var _ = real(p) // ERROR "type \*\[1\]complex128|argument must have complex type"
var _ = imag(p) // ERROR "type \*\[1\]complex128|argument must have complex type"

View File

@ -9,7 +9,7 @@ package p
// Verify that the compiler complains even if the array
// has length 0.
var a [0]int
var _ = a[2:] // ERROR "invalid slice index 2"
var _ = a[2:] // ERROR "invalid slice index 2|array index out of bounds"
var b [1]int
var _ = b[2:] // ERROR "invalid slice index 2"
var _ = b[2:] // ERROR "invalid slice index 2|array index out of bounds"

View File

@ -9,7 +9,7 @@
package main
func f() { // ERROR "stack frame too large"
func f() { // GC_ERROR "stack frame too large"
var x [800e6]byte
g(x)
return

View File

@ -7,9 +7,9 @@
package p
func f() {
_ = int("1") // ERROR "cannot convert"
_ = bool(0) // ERROR "cannot convert"
_ = bool("false") // ERROR "cannot convert"
_ = int(false) // ERROR "cannot convert"
_ = string(true) // ERROR "cannot convert"
_ = int("1") // ERROR "cannot convert|invalid type conversion"
_ = bool(0) // ERROR "cannot convert|invalid type conversion"
_ = bool("false") // ERROR "cannot convert|invalid type conversion"
_ = int(false) // ERROR "cannot convert|invalid type conversion"
_ = string(true) // ERROR "cannot convert|invalid type conversion"
}

View File

@ -7,5 +7,5 @@
package p
func f() {
1 = 2 // ERROR "cannot assign to 1"
1 = 2 // ERROR "cannot assign to 1|invalid left hand side"
}

View File

@ -6,4 +6,4 @@
package main
var main = func() {} // ERROR "must be func"
var main = func() {} // ERROR "must be func|redefinition"

View File

@ -24,5 +24,5 @@ func g() {
func h() {
type T4 struct{ m map[T4]int } // ERROR "invalid map key"
type _ map[T4]int // ERROR "invalid map key"
type _ map[T4]int // GC_ERROR "invalid map key"
}

View File

@ -7,39 +7,39 @@
package p
func f() {
_ = bool("") // ERROR "cannot convert .. \(type untyped string\) to type bool"
_ = bool(1) // ERROR "cannot convert 1 \(type untyped int\) to type bool"
_ = bool(1.0) // ERROR "cannot convert 1 \(type untyped float\) to type bool"
_ = bool(-4 + 2i) // ERROR "cannot convert -4 \+ 2i \(type untyped complex\) to type bool"
_ = bool("") // ERROR "cannot convert .. \(type untyped string\) to type bool|invalid type conversion"
_ = bool(1) // ERROR "cannot convert 1 \(type untyped int\) to type bool|invalid type conversion"
_ = bool(1.0) // ERROR "cannot convert 1 \(type untyped float\) to type bool|invalid type conversion"
_ = bool(-4 + 2i) // ERROR "cannot convert -4 \+ 2i \(type untyped complex\) to type bool|invalid type conversion"
_ = string(true) // ERROR "cannot convert true \(type untyped bool\) to type string"
_ = string(true) // ERROR "cannot convert true \(type untyped bool\) to type string|invalid type conversion"
_ = string(-1)
_ = string(1.0) // ERROR "cannot convert 1 \(type untyped float\) to type string"
_ = string(-4 + 2i) // ERROR "cannot convert -4 \+ 2i \(type untyped complex\) to type string"
_ = string(1.0) // ERROR "cannot convert 1 \(type untyped float\) to type string|invalid type conversion"
_ = string(-4 + 2i) // ERROR "cannot convert -4 \+ 2i \(type untyped complex\) to type string|invalid type conversion"
_ = int("") // ERROR "cannot convert .. \(type untyped string\) to type int"
_ = int(true) // ERROR "cannot convert true \(type untyped bool\) to type int"
_ = int("") // ERROR "cannot convert .. \(type untyped string\) to type int|invalid type conversion"
_ = int(true) // ERROR "cannot convert true \(type untyped bool\) to type int|invalid type conversion"
_ = int(-1)
_ = int(1)
_ = int(1.0)
_ = int(-4 + 2i) // ERROR "truncated to integer"
_ = uint("") // ERROR "cannot convert .. \(type untyped string\) to type uint"
_ = uint(true) // ERROR "cannot convert true \(type untyped bool\) to type uint"
_ = uint(-1) // ERROR "constant -1 overflows uint"
_ = uint("") // ERROR "cannot convert .. \(type untyped string\) to type uint|invalid type conversion"
_ = uint(true) // ERROR "cannot convert true \(type untyped bool\) to type uint|invalid type conversion"
_ = uint(-1) // ERROR "constant -1 overflows uint|integer constant overflow"
_ = uint(1)
_ = uint(1.0)
_ = uint(-4 + 2i) // ERROR "constant -4 overflows uint" "truncated to integer"
_ = float64("") // ERROR "cannot convert .. \(type untyped string\) to type float64"
_ = float64(true) // ERROR "cannot convert true \(type untyped bool\) to type float64"
_ = float64("") // ERROR "cannot convert .. \(type untyped string\) to type float64|invalid type conversion"
_ = float64(true) // ERROR "cannot convert true \(type untyped bool\) to type float64|invalid type conversion"
_ = float64(-1)
_ = float64(1)
_ = float64(1.0)
_ = float64(-4 + 2i) // ERROR "truncated to real"
_ = float64(-4 + 2i) // ERROR "truncated to"
_ = complex128("") // ERROR "cannot convert .. \(type untyped string\) to type complex128"
_ = complex128(true) // ERROR "cannot convert true \(type untyped bool\) to type complex128"
_ = complex128("") // ERROR "cannot convert .. \(type untyped string\) to type complex128|invalid type conversion"
_ = complex128(true) // ERROR "cannot convert true \(type untyped bool\) to type complex128|invalid type conversion"
_ = complex128(-1)
_ = complex128(1)
_ = complex128(1.0)

View File

@ -8,7 +8,7 @@
package p
const X = Wrong(0) // ERROR "undefined: Wrong"
const X = Wrong(0) // ERROR "undefined: Wrong|undefined name .*Wrong"
func _() {
switch 0 {

View File

@ -8,7 +8,7 @@
package p
const X = Wrong(0) // ERROR "undefined: Wrong"
const X = Wrong(0) // ERROR "undefined: Wrong|reference to undefined name .*Wrong"
func _() {
switch interface{}(nil) {

View File

@ -12,7 +12,7 @@ func f1(x *[1<<30 - 1e6]byte) byte {
}
return 0
}
func f2(x *[1<<30 + 1e6]byte) byte { // ERROR "stack frame too large"
func f2(x *[1<<30 + 1e6]byte) byte { // GC_ERROR "stack frame too large"
for _, b := range *x {
return b
}

View File

@ -8,19 +8,19 @@
package p
func f3(x *[1 << 31]byte) byte { // ERROR "stack frame too large"
func f3(x *[1 << 31]byte) byte { // GC_ERROR "stack frame too large"
for _, b := range *x {
return b
}
return 0
}
func f4(x *[1 << 32]byte) byte { // ERROR "stack frame too large"
func f4(x *[1 << 32]byte) byte { // GC_ERROR "stack frame too large"
for _, b := range *x {
return b
}
return 0
}
func f5(x *[1 << 33]byte) byte { // ERROR "stack frame too large"
func f5(x *[1 << 33]byte) byte { // GC_ERROR "stack frame too large"
for _, b := range *x {
return b
}

View File

@ -13,8 +13,8 @@ type it struct {
func main() {
i1 := it{Floats: true}
if i1.floats { // ERROR "(type it .* field or method floats, but does have Floats)"
if i1.floats { // ERROR "(type it .* field or method floats, but does have Floats)|undefined field or method"
}
i2 := &it{floats: false} // ERROR "(but does have Floats)"
_ = &it{InneR: "foo"} // ERROR "(but does have inner)"
i2 := &it{floats: false} // ERROR "(but does have Floats)|unknown field|declared but not used"
_ = &it{InneR: "foo"} // ERROR "(but does have inner)|unknown field"
}

View File

@ -12,5 +12,5 @@ package main
func F() {
slice := []int{1, 2, 3}
len := int(2)
println(len(slice)) // ERROR "cannot call non-function len .type int., declared at"
println(len(slice)) // ERROR "cannot call non-function len .type int., declared at|expected function"
}

View File

@ -10,7 +10,7 @@
package p
type a struct{ b } // ERROR "invalid recursive type"
type b struct{ a }
type b struct{ a } // GCCGO_ERROR "invalid recursive type"
var x interface{}

View File

@ -8,11 +8,11 @@ package main
import "bytes"
type _ struct{ bytes.nonexist } // ERROR "unexported"
type _ struct{ bytes.nonexist } // ERROR "unexported|undefined"
type _ interface{ bytes.nonexist } // ERROR "unexported"
type _ interface{ bytes.nonexist } // ERROR "unexported|undefined|expected signature or type name"
func main() {
var _ bytes.Buffer
var _ bytes.buffer // ERROR "unexported"
var _ bytes.buffer // ERROR "unexported|undefined"
}

View File

@ -6,4 +6,4 @@
package p
var f = func() { f() } // ERROR "initialization loop"
var f = func() { f() } // ERROR "initialization loop|initialization expression for .*f.* depends upon itself"

View File

@ -21,22 +21,22 @@ type Bar struct {
}
func main() {
_ = Foo{
_ = Foo{ // GCCGO_ERROR "too few expressions"
1,
2,
3, // ERROR "too few values in Foo{...}"
3, // GC_ERROR "too few values in Foo{...}"
}
_ = Foo{
1,
2,
3,
Bar{"A", "B"}, // ERROR "too many values in Bar{...}"
Bar{"A", "B"}, // ERROR "too many values in Bar{...}|too many expressions"
}
_ = Foo{
_ = Foo{ // GCCGO_ERROR "too few expressions"
1,
2,
Bar{"A", "B"}, // ERROR "too many values in Bar{...}" "too few values in Foo{...}"
Bar{"A", "B"}, // ERROR "too many values in Bar{...}|too many expressions" "too few values in Foo{...}"
}
}

View File

@ -7,10 +7,10 @@
package p
type I1 = interface {
I2
I2 // GCCGO_ERROR "invalid recursive interface"
}
// BAD: type loop should mention I1; see also #41669
type I2 interface { // ERROR "invalid recursive type I2\n\tLINE: I2 refers to\n\tLINE: I2$"
I1
type I2 interface { // GC_ERROR "invalid recursive type I2\n\tLINE: I2 refers to\n\tLINE: I2$"
I1 // GCCGO_ERROR "invalid recursive interface"
}

View File

@ -16,14 +16,14 @@ type large struct {
b [1500000000]byte
}
func (x large) f1() int { // ERROR "stack frame too large"
func (x large) f1() int { // GC_ERROR "stack frame too large"
return 5
}
func f2(x large) int { // ERROR "stack frame too large"
func f2(x large) int { // GC_ERROR "stack frame too large"
return 5
}
func f3() (x large, i int) { // ERROR "stack frame too large"
func f3() (x large, i int) { // GC_ERROR "stack frame too large"
return
}

View File

@ -9,13 +9,13 @@ package main
import "net/http"
var s = http.Server{}
var _ = s.doneChan // ERROR "s.doneChan undefined .cannot refer to unexported field or method doneChan.$"
var _ = s.DoneChan // ERROR "s.DoneChan undefined .type http.Server has no field or method DoneChan.$"
var _ = http.Server{tlsConfig: nil} // ERROR "unknown field 'tlsConfig' in struct literal.+ .but does have TLSConfig.$"
var _ = http.Server{DoneChan: nil} // ERROR "unknown field 'DoneChan' in struct literal of type http.Server$"
var _ = s.doneChan // ERROR "s.doneChan undefined .cannot refer to unexported field or method doneChan.$|unexported field or method"
var _ = s.DoneChan // ERROR "s.DoneChan undefined .type http.Server has no field or method DoneChan.$|undefined field or method"
var _ = http.Server{tlsConfig: nil} // ERROR "unknown field 'tlsConfig' in struct literal.+ .but does have TLSConfig.$|unknown field .?tlsConfig.? in .?http.Server"
var _ = http.Server{DoneChan: nil} // ERROR "unknown field 'DoneChan' in struct literal of type http.Server$|unknown field .?DoneChan.? in .?http.Server"
type foo struct {
bar int
}
var _ = &foo{bAr: 10} // ERROR "unknown field 'bAr' in struct literal.+ .but does have bar.$"
var _ = &foo{bAr: 10} // ERROR "unknown field 'bAr' in struct literal.+ .but does have bar.$|unknown field .?bAr.? in .?foo"