mirror of
https://github.com/golang/go
synced 2024-11-11 18:31:38 -07:00
test: match gofrontend error messages
These changes match the following gofrontend error messages: blank1.go:16:1: error: may not define methods on non-local type chan/perm.go:28:9: error: expected channel chan/perm.go:29:11: error: left operand of ‘<-’ must be channel chan/perm.go:69:9: error: argument must be channel complit1.go:25:16: error: attempt to slice object that is not array, slice, or string complit1.go:26:16: error: attempt to slice object that is not array, slice, or string complit1.go:27:17: error: attempt to slice object that is not array, slice, or string complit1.go:49:41: error: may only omit types within composite literals of slice, array, or map type complit1.go:50:14: error: expected struct, slice, array, or map type for composite literal convlit.go:24:9: error: invalid type conversion (cannot use type unsafe.Pointer as type string) convlit.go:25:9: error: invalid type conversion (cannot use type unsafe.Pointer as type float64) convlit.go:26:9: error: invalid type conversion (cannot use type unsafe.Pointer as type int) ddd1.go:63:9: error: invalid use of ‘...’ calling non-variadic function fixedbugs/bug176.go:12:18: error: index expression is not integer constant fixedbugs/bug332.go:17:10: error: use of undefined type ‘T’ fixedbugs/issue4232.go:22:16: error: integer constant overflow fixedbugs/issue4232.go:33:16: error: integer constant overflow fixedbugs/issue4232.go:44:25: error: integer constant overflow fixedbugs/issue4232.go:55:16: error: integer constant overflow fixedbugs/issue4458.go:19:14: error: type has no method ‘foo’ fixedbugs/issue5172.go:24:14: error: too many expressions for struct init.go:17:9: error: reference to undefined name ‘runtime’ initializerr.go:26:29: error: duplicate value for index 1 interface/explicit.go:60:14: error: type assertion only valid for interface types label.go:64:9: error: reference to undefined label ‘go2’ label1.go:18:97: error: continue statement not within for label1.go:22:97: error: continue statement not within for label1.go:106:89: error: continue statement not within for label1.go:108:26: error: invalid continue label ‘on’ label1.go:111:118: error: break statement not within for or switch or select label1.go:113:23: error: invalid break label ‘dance’ map1.go:64:9: error: not enough arguments map1.go:65:9: error: not enough arguments map1.go:67:9: error: argument 1 must be a map method2.go:36:11: error: reference to undefined field or method ‘val’ method2.go:37:11: error: reference to undefined field or method ‘val’ method2.go:41:12: error: method requires pointer (use ‘(*T).g’) syntax/chan1.go:13:19: error: send statement used as value; use select for non-blocking send syntax/chan1.go:17:11: error: send statement used as value; use select for non-blocking send Change-Id: I98047b60a376e3d2788836300f7fcac3f2c285cb Reviewed-on: https://go-review.googlesource.com/c/go/+/273527 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
cb84d831c9
commit
b94346e69b
@ -13,7 +13,7 @@ var t struct {
|
||||
_ int
|
||||
}
|
||||
|
||||
func (x int) _() { // ERROR "cannot define new methods on non-local type"
|
||||
func (x int) _() { // ERROR "methods on non-local type"
|
||||
println(x)
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,8 @@ func main() {
|
||||
cs = cr // ERROR "illegal types|incompatible|cannot"
|
||||
|
||||
var n int
|
||||
<-n // ERROR "receive from non-chan"
|
||||
n <- 2 // ERROR "send to non-chan"
|
||||
<-n // ERROR "receive from non-chan|expected channel"
|
||||
n <- 2 // ERROR "send to non-chan|must be channel"
|
||||
|
||||
c <- 0 // ok
|
||||
<-c // ok
|
||||
@ -66,5 +66,5 @@ func main() {
|
||||
close(c)
|
||||
close(cs)
|
||||
close(cr) // ERROR "receive"
|
||||
close(n) // ERROR "invalid operation.*non-chan type"
|
||||
close(n) // ERROR "invalid operation.*non-chan type|must be channel"
|
||||
}
|
||||
|
@ -22,9 +22,9 @@ var (
|
||||
_ = m[0][:] // ERROR "slice of unaddressable value"
|
||||
_ = f()[:] // ERROR "slice of unaddressable value"
|
||||
|
||||
_ = 301[:] // ERROR "cannot slice"
|
||||
_ = 3.1[:] // ERROR "cannot slice"
|
||||
_ = true[:] // ERROR "cannot slice"
|
||||
_ = 301[:] // ERROR "cannot slice|attempt to slice object that is not"
|
||||
_ = 3.1[:] // ERROR "cannot slice|attempt to slice object that is not"
|
||||
_ = true[:] // ERROR "cannot slice|attempt to slice object that is not"
|
||||
|
||||
// these are okay because they are slicing a pointer to an array
|
||||
_ = (&[3]int{1, 2, 3})[:]
|
||||
@ -46,8 +46,8 @@ var (
|
||||
_ = &T{0, 0, "", nil} // ok
|
||||
_ = &T{i: 0, f: 0, s: "", next: {}} // ERROR "missing type in composite literal|omit types within composite literal"
|
||||
_ = &T{0, 0, "", {}} // ERROR "missing type in composite literal|omit types within composite literal"
|
||||
_ = TP{i: 0, f: 0, s: "", next: {}} // ERROR "invalid composite literal type TP"
|
||||
_ = &Ti{} // ERROR "invalid composite literal type Ti"
|
||||
_ = TP{i: 0, f: 0, s: "", next: {}} // ERROR "invalid composite literal type TP|omit types within composite literal"
|
||||
_ = &Ti{} // ERROR "invalid composite literal type Ti|expected.*type for composite literal"
|
||||
)
|
||||
|
||||
type M map[T]T
|
||||
|
@ -21,9 +21,9 @@ var x6 = int(1e100) // ERROR "overflow"
|
||||
var x7 = float32(1e1000) // ERROR "overflow"
|
||||
|
||||
// unsafe.Pointer can only convert to/from uintptr
|
||||
var _ = string(unsafe.Pointer(uintptr(65))) // ERROR "convert"
|
||||
var _ = float64(unsafe.Pointer(uintptr(65))) // ERROR "convert"
|
||||
var _ = int(unsafe.Pointer(uintptr(65))) // ERROR "convert"
|
||||
var _ = string(unsafe.Pointer(uintptr(65))) // ERROR "convert|conversion"
|
||||
var _ = float64(unsafe.Pointer(uintptr(65))) // ERROR "convert|conversion"
|
||||
var _ = int(unsafe.Pointer(uintptr(65))) // ERROR "convert|conversion"
|
||||
|
||||
// implicit conversions merit scrutiny
|
||||
var s string
|
||||
|
@ -60,5 +60,5 @@ func bad(args ...int) {
|
||||
_ = [...]byte("foo") // ERROR "[.][.][.]"
|
||||
_ = [...][...]int{{1,2,3},{4,5,6}} // ERROR "[.][.][.]"
|
||||
|
||||
Foo(x...) // ERROR "invalid use of [.][.][.] in call"
|
||||
Foo(x...) // ERROR "invalid use of .*[.][.][.]"
|
||||
}
|
||||
|
@ -9,6 +9,6 @@ package main
|
||||
var x int
|
||||
|
||||
var a = []int{ x: 1} // ERROR "constant"
|
||||
var b = [...]int{x: 1}
|
||||
var b = [...]int{x: 1} // GCCGO_ERROR "constant"
|
||||
var c = map[int]int{ x: 1}
|
||||
|
||||
|
@ -14,4 +14,4 @@ func main() {}
|
||||
|
||||
// important: no newline on end of next line.
|
||||
// 6g used to print <epoch> instead of bug332.go:111
|
||||
func (t *T) F() {} // ERROR "undefined: T"
|
||||
func (t *T) F() {} // ERROR "undefined.*T"
|
@ -19,7 +19,7 @@ func f() {
|
||||
_ = a[10:10]
|
||||
_ = a[9:12] // ERROR "invalid slice index 12|index out of bounds"
|
||||
_ = a[11:12] // ERROR "invalid slice index 11|index out of bounds"
|
||||
_ = a[1<<100 : 1<<110] // ERROR "overflows int" "invalid slice index 1 << 100|index out of bounds"
|
||||
_ = a[1<<100 : 1<<110] // ERROR "overflows int|integer constant overflow" "invalid slice index 1 << 100|index out of bounds"
|
||||
|
||||
var s []int
|
||||
_ = s[-1] // ERROR "invalid slice index -1|index out of bounds"
|
||||
@ -30,7 +30,7 @@ func f() {
|
||||
_ = s[10:10]
|
||||
_ = s[9:12]
|
||||
_ = s[11:12]
|
||||
_ = s[1<<100 : 1<<110] // ERROR "overflows int" "invalid slice index 1 << 100|index out of bounds"
|
||||
_ = s[1<<100 : 1<<110] // ERROR "overflows int|integer constant overflow" "invalid slice index 1 << 100|index out of bounds"
|
||||
|
||||
const c = "foofoofoof"
|
||||
_ = c[-1] // ERROR "invalid string index -1|index out of bounds"
|
||||
@ -41,7 +41,7 @@ func f() {
|
||||
_ = c[10:10]
|
||||
_ = c[9:12] // ERROR "invalid slice index 12|index out of bounds"
|
||||
_ = c[11:12] // ERROR "invalid slice index 11|index out of bounds"
|
||||
_ = c[1<<100 : 1<<110] // ERROR "overflows int" "invalid slice index 1 << 100|index out of bounds"
|
||||
_ = c[1<<100 : 1<<110] // ERROR "overflows int|integer constant overflow" "invalid slice index 1 << 100|index out of bounds"
|
||||
|
||||
var t string
|
||||
_ = t[-1] // ERROR "invalid string index -1|index out of bounds"
|
||||
@ -52,5 +52,5 @@ func f() {
|
||||
_ = t[10:10]
|
||||
_ = t[9:12]
|
||||
_ = t[11:12]
|
||||
_ = t[1<<100 : 1<<110] // ERROR "overflows int" "invalid slice index 1 << 100|index out of bounds"
|
||||
_ = t[1<<100 : 1<<110] // ERROR "overflows int|integer constant overflow" "invalid slice index 1 << 100|index out of bounds"
|
||||
}
|
||||
|
@ -16,5 +16,5 @@ func (T) foo() {}
|
||||
func main() {
|
||||
av := T{}
|
||||
pav := &av
|
||||
(**T).foo(&pav) // ERROR "no method foo|requires named type or pointer to named"
|
||||
(**T).foo(&pav) // ERROR "no method .*foo|requires named type or pointer to named"
|
||||
}
|
||||
|
@ -21,6 +21,6 @@ func main() {
|
||||
go f.bar() // ERROR "undefined"
|
||||
defer f.bar() // ERROR "undefined"
|
||||
|
||||
t := T{1} // ERROR "too many values"
|
||||
t := T{1} // ERROR "too many"
|
||||
go t.Bar()
|
||||
}
|
||||
|
@ -14,6 +14,6 @@ func init() {
|
||||
|
||||
func main() {
|
||||
init() // ERROR "undefined.*init"
|
||||
runtime.init() // ERROR "undefined.*runtime\.init"
|
||||
runtime.init() // ERROR "undefined.*runtime\.init|reference to undefined name"
|
||||
var _ = init // ERROR "undefined.*init"
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ var a2 = S { Y: 3, Z: 2, Y: 3 } // ERROR "duplicate"
|
||||
var a3 = T { S{}, 2, 3, 4, 5, 6 } // ERROR "convert|too many"
|
||||
var a4 = [5]byte{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 } // ERROR "index|too many"
|
||||
var a5 = []byte { x: 2 } // ERROR "index"
|
||||
var a6 = []byte{1: 1, 2: 2, 1: 3} // ERROR "duplicate index"
|
||||
var a6 = []byte{1: 1, 2: 2, 1: 3} // ERROR "duplicate"
|
||||
|
||||
var ok1 = S { } // should be ok
|
||||
var ok2 = T { S: ok1 } // should be ok
|
||||
|
@ -57,7 +57,7 @@ func main() {
|
||||
|
||||
// cannot type-assert non-interfaces
|
||||
f := 2.0
|
||||
_ = f.(int) // ERROR "non-interface type"
|
||||
_ = f.(int) // ERROR "non-interface type|only valid for interface types"
|
||||
|
||||
}
|
||||
|
||||
|
@ -61,5 +61,5 @@ L10:
|
||||
|
||||
goto L10
|
||||
|
||||
goto go2 // ERROR "label go2 not defined"
|
||||
goto go2 // ERROR "label go2 not defined|reference to undefined label .*go2"
|
||||
}
|
||||
|
@ -15,11 +15,11 @@ var x int
|
||||
func f1() {
|
||||
switch x {
|
||||
case 1:
|
||||
continue // ERROR "continue is not in a loop$"
|
||||
continue // ERROR "continue is not in a loop$|continue statement not within for"
|
||||
}
|
||||
select {
|
||||
default:
|
||||
continue // ERROR "continue is not in a loop$"
|
||||
continue // ERROR "continue is not in a loop$|continue statement not within for"
|
||||
}
|
||||
|
||||
}
|
||||
@ -103,14 +103,14 @@ L5:
|
||||
}
|
||||
}
|
||||
|
||||
continue // ERROR "continue is not in a loop$"
|
||||
continue // ERROR "continue is not in a loop$|continue statement not within for"
|
||||
for {
|
||||
continue on // ERROR "continue label not defined: on"
|
||||
continue on // ERROR "continue label not defined: on|invalid continue label .*on"
|
||||
}
|
||||
|
||||
break // ERROR "break is not in a loop, switch, or select"
|
||||
break // ERROR "break is not in a loop, switch, or select|break statement not within for or switch or select"
|
||||
for {
|
||||
break dance // ERROR "break label not defined: dance"
|
||||
break dance // ERROR "break label not defined: dance|invalid break label .*dance"
|
||||
}
|
||||
|
||||
for {
|
||||
|
@ -61,8 +61,8 @@ type T8 struct { F *T7 }
|
||||
|
||||
func main() {
|
||||
m := make(map[int]int)
|
||||
delete() // ERROR "missing arguments"
|
||||
delete(m) // ERROR "missing second \(key\) argument"
|
||||
delete() // ERROR "missing arguments|not enough arguments"
|
||||
delete(m) // ERROR "missing second \(key\) argument|not enough arguments"
|
||||
delete(m, 2, 3) // ERROR "too many arguments"
|
||||
delete(1, m) // ERROR "first argument to delete must be map"
|
||||
}
|
||||
delete(1, m) // ERROR "first argument to delete must be map|argument 1 must be a map"
|
||||
}
|
||||
|
@ -33,9 +33,9 @@ var _ = (*Val).val // ERROR "method"
|
||||
var v Val
|
||||
var pv = &v
|
||||
|
||||
var _ = pv.val() // ERROR "pv.val undefined"
|
||||
var _ = pv.val // ERROR "pv.val undefined"
|
||||
var _ = pv.val() // ERROR "undefined"
|
||||
var _ = pv.val // ERROR "undefined"
|
||||
|
||||
func (t *T) g() int { return t.a }
|
||||
|
||||
var _ = (T).g() // ERROR "needs pointer receiver|undefined"
|
||||
var _ = (T).g() // ERROR "needs pointer receiver|undefined|method requires pointer"
|
||||
|
@ -10,8 +10,8 @@ var c chan int
|
||||
var v int
|
||||
|
||||
func main() {
|
||||
if c <- v { // ERROR "cannot use c <- v as value"
|
||||
if c <- v { // ERROR "cannot use c <- v as value|send statement used as value"
|
||||
}
|
||||
}
|
||||
|
||||
var _ = c <- v // ERROR "unexpected <-"
|
||||
var _ = c <- v // ERROR "unexpected <-|send statement used as value"
|
||||
|
Loading…
Reference in New Issue
Block a user