[dev.typeparams] test: adjust more test cases to match compiler -G output

With this CL, the first ~500 errorcheck tests pass when running

go run run.go -v -G

in the $GOROOT/test directory (the log output includes a few dozen
tests that are currently skipped).

Change-Id: I9eaa2319fb39a090df54f8699ddc29ffe58b1bf1
Reviewed-on: https://go-review.googlesource.com/c/go/+/274975
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
Robert Griesemer 2020-12-01 17:37:12 -08:00
parent 07d32c8183
commit 7a1aa7dfaf
21 changed files with 43 additions and 34 deletions

View file

@ -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|not a channel"
}

View file

@ -7,5 +7,5 @@
package main
func f (x, // GCCGO_ERROR "previous"
x int) { // ERROR "duplicate argument|redefinition"
x int) { // ERROR "duplicate argument|redefinition|redeclared"
}

View file

@ -8,4 +8,5 @@ package main
func main() {
var s string = nil; // ERROR "illegal|invalid|incompatible|cannot"
_ = s
}

View file

@ -6,7 +6,7 @@
package main
const x x = 2 // ERROR "loop|type"
const x x = 2 // ERROR "loop|type|cycle"
/*
bug081.go:3: first constant must evaluate an expression

View file

@ -42,5 +42,5 @@ func main() {
const h float64 = 3.14;
i = h; // ERROR "convert|incompatible|cannot"
i = int(h); // ERROR "truncate"
i = int(h); // ERROR "truncate|cannot convert"
}

View file

@ -8,5 +8,5 @@ package main
func main() {
// should allow at most 2 sizes
a := make([]int, 10, 20, 30, 40); // ERROR "too many"
a := make([]int, 10, 20, 30, 40); // ERROR "too many|expects 2 or 3 arguments; found 5"
}

View file

@ -9,4 +9,5 @@ package main
func main() {
const a uint64 = 10;
var b int64 = a; // ERROR "convert|cannot|incompatible"
_ = b
}

View file

@ -7,5 +7,5 @@
package main
type T struct {
x, x int // ERROR "duplicate"
x, x int // ERROR "duplicate|redeclared"
}

View file

@ -7,7 +7,7 @@
package main
var (
a, b = f() // ERROR "initialization loop|depends upon itself"
a, b = f() // ERROR "initialization loop|depends upon itself|initialization cycle"
c = b
)

View file

@ -9,6 +9,6 @@ package main
func f() (int, bool) { return 0, true }
func main() {
x, y := f(), 2; // ERROR "multi"
x, y := f(), 2; // ERROR "multi|2-valued"
_, _ = x, y
}

View file

@ -11,8 +11,8 @@ var s string;
var m map[string]int;
func main() {
println(t["hi"]); // ERROR "non-integer slice index|must be integer"
println(s["hi"]); // ERROR "non-integer string index|must be integer"
println(m[0]); // ERROR "cannot use.*as type string"
println(t["hi"]); // ERROR "non-integer slice index|must be integer|cannot convert"
println(s["hi"]); // ERROR "non-integer string index|must be integer|cannot convert"
println(m[0]); // ERROR "cannot use.*as type string|cannot convert"
}

View file

@ -9,6 +9,6 @@
package main
type A struct { a A } // ERROR "recursive"
type A struct { a A } // ERROR "recursive|cycle"
func foo() { new(A).bar() }
func (a A) bar() {}

View file

@ -18,4 +18,4 @@ func f() {
}
}
var m = map[string]F{"f": f} // ERROR "initialization loop|depends upon itself"
var m = map[string]F{"f": f} // ERROR "initialization loop|depends upon itself|initialization cycle"

View file

@ -6,5 +6,5 @@
package main
type T T // ERROR "recursive"
type T T // ERROR "recursive|cycle"

View file

@ -8,6 +8,6 @@
package main
type A [...]int // ERROR "outside of array literal"
type A [...]int // ERROR "outside of array literal|invalid use of \[\.\.\.\]"

View file

@ -9,14 +9,14 @@
package main
func f1() {
a, b := f() // ERROR "assignment mismatch|does not match"
a, b := f() // ERROR "assignment mismatch|does not match|cannot initialize"
_ = a
_ = b
}
func f2() {
var a, b int
a, b = f() // ERROR "assignment mismatch|does not match"
a, b = f() // ERROR "assignment mismatch|does not match|cannot assign"
_ = a
_ = b
}

View file

@ -48,25 +48,25 @@ func main() {
check("t.M()", t.M())
check("pt.M()", pt.M())
check("ti.M()", ti.M())
check("pti.M()", pti.M()) // ERROR "pointer to interface, not interface"
check("pti.M()", pti.M()) // ERROR "pointer to interface, not interface|no field or method M"
check("s.M()", s.M())
check("ps.M()", ps.M())
i = t
check("i = t; i.M()", i.M())
check("i = t; pi.M()", pi.M()) // ERROR "pointer to interface, not interface"
check("i = t; pi.M()", pi.M()) // ERROR "pointer to interface, not interface|no field or method M"
i = pt
check("i = pt; i.M()", i.M())
check("i = pt; pi.M()", pi.M()) // ERROR "pointer to interface, not interface"
check("i = pt; pi.M()", pi.M()) // ERROR "pointer to interface, not interface|no field or method M"
i = s
check("i = s; i.M()", i.M())
check("i = s; pi.M()", pi.M()) // ERROR "pointer to interface, not interface"
check("i = s; pi.M()", pi.M()) // ERROR "pointer to interface, not interface|no field or method M"
i = ps
check("i = ps; i.M()", i.M())
check("i = ps; pi.M()", pi.M()) // ERROR "pointer to interface, not interface"
check("i = ps; pi.M()", pi.M()) // ERROR "pointer to interface, not interface|no field or method M"
if !ok {
println("BUG: interface10")

View file

@ -38,7 +38,7 @@ var e E
func main() {
e = t // ok
t = e // ERROR "need explicit|need type assertion"
t = e // ERROR "need explicit|need type assertion|incompatible type"
// neither of these can work,
// because i has an extra method
@ -47,17 +47,17 @@ func main() {
t = i // ERROR "incompatible|assignment$"
i = i2 // ok
i2 = i // ERROR "incompatible|missing N method"
i2 = i // ERROR "incompatible|missing N method|cannot convert"
i = I(i2) // ok
i2 = I2(i) // ERROR "invalid|missing N method"
i2 = I2(i) // ERROR "invalid|missing N method|cannot convert"
e = E(t) // ok
t = T(e) // ERROR "need explicit|need type assertion|incompatible"
t = T(e) // ERROR "need explicit|need type assertion|incompatible|cannot convert"
// cannot type-assert non-interfaces
f := 2.0
_ = f.(int) // ERROR "non-interface type"
_ = f.(int) // ERROR "non-interface type|not an interface type"
}
@ -83,8 +83,8 @@ var jj Int
var m1 M = ii // ERROR "incompatible|missing"
var m2 M = jj // ERROR "incompatible|wrong type for M method"
var m3 = M(ii) // ERROR "invalid|missing"
var m4 = M(jj) // ERROR "invalid|wrong type for M method"
var m3 = M(ii) // ERROR "invalid|missing|cannot convert"
var m4 = M(jj) // ERROR "invalid|wrong type for M method|cannot convert"
type B1 interface {
_() // ERROR "methods must have a unique non-blank name"
@ -101,5 +101,9 @@ func (t *T2) M() {}
func (t *T2) _() {}
// Check that nothing satisfies an interface with blank methods.
var b1 B1 = &T2{} // ERROR "incompatible|missing _ method"
var b2 B2 = &T2{} // ERROR "incompatible|missing _ method"
// Disabled this test as it's not clear we need this behavior.
// See also issue #42964.
/*
var b1 B1 = &T2{} // "incompatible|missing _ method"
var b2 B2 = &T2{} // "incompatible|missing _ method"
*/

View file

@ -32,7 +32,9 @@ func AddInst(Inst) *Inst {
func main() {
print("call addinst\n")
var x Inst = AddInst(new(Start)) // ERROR "pointer to interface"
var x Inst = AddInst(new(Start)) // ERROR "pointer to interface|incompatible type"
_ = x
print("return from addinst\n")
var y *Inst = new(Start) // ERROR "pointer to interface|incompatible type"
_ = y
}

View file

@ -37,14 +37,14 @@ func main() {
var sp SP
v = t
p = t // ERROR "does not implement|requires a pointer"
p = t // ERROR "does not implement|requires a pointer|cannot use"
_, _ = v, p
v = &t
p = &t
_, _ = v, p
v = s
p = s // ERROR "does not implement|requires a pointer"
p = s // ERROR "does not implement|requires a pointer|cannot use"
_, _ = v, p
v = &s
p = &s

View file

@ -813,6 +813,7 @@ func (t *test) run() {
"wb",
"append",
"slice",
"typeassert",
"ssa/check_bce/debug",
"ssa/intrinsics/debug",
"ssa/prove/debug",