Skip to content

Commit

Permalink
[dev.typeparams] test: adjust more test cases to match compiler -G ou…
Browse files Browse the repository at this point in the history
…tput

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>
  • Loading branch information
griesemer committed Dec 3, 2020
1 parent 07d32c8 commit 7a1aa7d
Show file tree
Hide file tree
Showing 21 changed files with 43 additions and 34 deletions.
2 changes: 1 addition & 1 deletion test/chan/perm.go
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion test/fixedbugs/bug040.go
Expand Up @@ -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"
}
1 change: 1 addition & 0 deletions test/fixedbugs/bug062.go
Expand Up @@ -8,4 +8,5 @@ package main

func main() {
var s string = nil; // ERROR "illegal|invalid|incompatible|cannot"
_ = s
}
2 changes: 1 addition & 1 deletion test/fixedbugs/bug081.go
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/fixedbugs/bug090.go
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion test/fixedbugs/bug122.go
Expand Up @@ -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"
}
1 change: 1 addition & 0 deletions test/fixedbugs/bug131.go
Expand Up @@ -9,4 +9,5 @@ package main
func main() {
const a uint64 = 10;
var b int64 = a; // ERROR "convert|cannot|incompatible"
_ = b
}
2 changes: 1 addition & 1 deletion test/fixedbugs/bug132.go
Expand Up @@ -7,5 +7,5 @@
package main

type T struct {
x, x int // ERROR "duplicate"
x, x int // ERROR "duplicate|redeclared"
}
2 changes: 1 addition & 1 deletion test/fixedbugs/bug13343.go
Expand Up @@ -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
)

Expand Down
2 changes: 1 addition & 1 deletion test/fixedbugs/bug175.go
Expand Up @@ -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
}
6 changes: 3 additions & 3 deletions test/fixedbugs/bug205.go
Expand Up @@ -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"
}

2 changes: 1 addition & 1 deletion test/fixedbugs/bug215.go
Expand Up @@ -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() {}
2 changes: 1 addition & 1 deletion test/fixedbugs/bug223.go
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion test/fixedbugs/bug224.go
Expand Up @@ -6,5 +6,5 @@

package main

type T T // ERROR "recursive"
type T T // ERROR "recursive|cycle"

2 changes: 1 addition & 1 deletion test/fixedbugs/bug280.go
Expand Up @@ -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 \[\.\.\.\]"


4 changes: 2 additions & 2 deletions test/fixedbugs/bug289.go
Expand Up @@ -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
}
Expand Down
10 changes: 5 additions & 5 deletions test/interface/embed2.go
Expand Up @@ -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")
Expand Down
22 changes: 13 additions & 9 deletions test/interface/explicit.go
Expand Up @@ -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
Expand All @@ -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"

}

Expand All @@ -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"
Expand All @@ -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"
*/
4 changes: 3 additions & 1 deletion test/interface/pointer.go
Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions test/interface/receiver1.go
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/run.go
Expand Up @@ -813,6 +813,7 @@ func (t *test) run() {
"wb",
"append",
"slice",
"typeassert",
"ssa/check_bce/debug",
"ssa/intrinsics/debug",
"ssa/prove/debug",
Expand Down

0 comments on commit 7a1aa7d

Please sign in to comment.