Skip to content

Commit

Permalink
[dev.typeparams] test: enable some more errorcheck tests
Browse files Browse the repository at this point in the history
Change-Id: I103e3eeacd5b11efd63c965482a626878ba5ac81
Reviewed-on: https://go-review.googlesource.com/c/go/+/275216
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 4, 2020
1 parent 9ff27e9 commit 02820d6
Show file tree
Hide file tree
Showing 29 changed files with 100 additions and 124 deletions.
8 changes: 4 additions & 4 deletions test/copy1.go
Expand Up @@ -17,11 +17,11 @@ func main() {
_ = copy() // ERROR "not enough arguments"
_ = copy(1, 2, 3) // ERROR "too many arguments"

_ = copy(si, "hi") // ERROR "have different element types.*int.*string"
_ = copy(si, "hi") // ERROR "have different element types(.*int.*string| int and byte)"
_ = copy(si, sf) // ERROR "have different element types.*int.*float64"

_ = copy(1, 2) // ERROR "must be slices; have int, int"
_ = copy(1, si) // ERROR "first argument to copy should be"
_ = copy(si, 2) // ERROR "second argument to copy should be"
_ = copy(1, 2) // ERROR "must be slices; have int, int|expects slice arguments"
_ = copy(1, si) // ERROR "first argument to copy should be|expects slice arguments"
_ = copy(si, 2) // ERROR "second argument to copy should be|expects slice arguments"

}
2 changes: 1 addition & 1 deletion test/fixedbugs/issue10975.go
Expand Up @@ -10,7 +10,7 @@
package main

type I interface {
int // ERROR "interface contains embedded non-interface int"
int // ERROR "interface contains embedded non-interface int|not an interface"
}

func New() I {
Expand Down
4 changes: 2 additions & 2 deletions test/fixedbugs/issue11361.go
Expand Up @@ -6,6 +6,6 @@

package a

import "fmt" // ERROR "imported and not used"
import "fmt" // ERROR "imported and not used|imported but not used"

const n = fmt // ERROR "fmt without selector"
const n = fmt // ERROR "fmt without selector|not in selector"
12 changes: 6 additions & 6 deletions test/fixedbugs/issue11371.go
Expand Up @@ -9,9 +9,9 @@

package issue11371

const a int = 1.1 // ERROR "constant 1.1 truncated to integer"
const b int = 1e20 // ERROR "overflows int"
const c int = 1 + 1e-100 // ERROR "constant truncated to integer"
const d int = 1 - 1e-100 // ERROR "constant truncated to integer"
const e int = 1.00000001 // ERROR "constant truncated to integer"
const f int = 0.00000001 // ERROR "constant 1e-08 truncated to integer"
const a int = 1.1 // ERROR "constant 1.1 truncated to integer|truncated to int"
const b int = 1e20 // ERROR "overflows int|truncated to int"
const c int = 1 + 1e-100 // ERROR "constant truncated to integer|truncated to int"
const d int = 1 - 1e-100 // ERROR "constant truncated to integer|truncated to int"
const e int = 1.00000001 // ERROR "constant truncated to integer|truncated to int"
const f int = 0.00000001 // ERROR "constant 1e-08 truncated to integer|truncated to int"
8 changes: 4 additions & 4 deletions test/fixedbugs/issue8385.go
Expand Up @@ -27,16 +27,16 @@ func (t T) M(x int) {
func g() func(int)

func main() {
Fooer.Foo(5, 6) // ERROR "not enough arguments in call to method expression Fooer.Foo"
Fooer.Foo(5, 6) // ERROR "not enough arguments in call to method expression Fooer.Foo|not enough arguments in call"

var i I
var t *T

g()() // ERROR "not enough arguments in call to g\(\)"
f() // ERROR "not enough arguments in call to f"
i.M() // ERROR "not enough arguments in call to i\.M"
I.M() // ERROR "not enough arguments in call to method expression I\.M"
I.M() // ERROR "not enough arguments in call to method expression I\.M|not enough arguments in call"
t.M() // ERROR "not enough arguments in call to t\.M"
T.M() // ERROR "not enough arguments in call to method expression T\.M"
(*T).M() // ERROR "not enough arguments in call to method expression \(\*T\)\.M"
T.M() // ERROR "not enough arguments in call to method expression T\.M|not enough arguments in call"
(*T).M() // ERROR "not enough arguments in call to method expression \(\*T\)\.M|not enough arguments in call"
}
6 changes: 3 additions & 3 deletions test/fixedbugs/issue8438.go
Expand Up @@ -10,8 +10,8 @@
package main

func main() {
_ = []byte{"foo"} // ERROR "cannot use"
_ = []int{"foo"} // ERROR "cannot use"
_ = []rune{"foo"} // ERROR "cannot use"
_ = []byte{"foo"} // ERROR "cannot use|cannot convert"
_ = []int{"foo"} // ERROR "cannot use|cannot convert"
_ = []rune{"foo"} // ERROR "cannot use|cannot convert"
_ = []string{"foo"} // OK
}
2 changes: 1 addition & 1 deletion test/fixedbugs/issue8440.go
Expand Up @@ -7,5 +7,5 @@
package main

func main() {
n.foo = 6 // ERROR "undefined: n in n.foo"
n.foo = 6 // ERROR "undefined: n in n.foo|undefined: n"
}
2 changes: 1 addition & 1 deletion test/fixedbugs/issue8745.go
Expand Up @@ -9,5 +9,5 @@
package p

func f(s string) {
var _ float64 = s[2] // ERROR "cannot use.*type byte.*as type float64"
var _ float64 = s[2] // ERROR "cannot use.*type byte.*as type float64|cannot use .* as float64 value"
}
1 change: 1 addition & 0 deletions test/fixedbugs/issue9083.go
Expand Up @@ -13,6 +13,7 @@ const zero = 0

func main() {
var x int
_ = x
x = make(map[int]int) // ERROR "cannot use make\(map\[int\]int\)|incompatible"
x = make(map[int]int, 0) // ERROR "cannot use make\(map\[int\]int, 0\)|incompatible"
x = make(map[int]int, zero) // ERROR "cannot use make\(map\[int\]int, zero\)|incompatible"
Expand Down
12 changes: 6 additions & 6 deletions test/fixedbugs/issue9370.go
Expand Up @@ -67,12 +67,12 @@ var (
_ = 1 != e
_ = 1 >= e // ERROR "invalid operation.*not defined"

_ = i == 1 // ERROR "invalid operation.*mismatched types"
_ = i != 1 // ERROR "invalid operation.*mismatched types"
_ = i >= 1 // ERROR "invalid operation.*mismatched types"
_ = 1 == i // ERROR "invalid operation.*mismatched types"
_ = 1 != i // ERROR "invalid operation.*mismatched types"
_ = 1 >= i // ERROR "invalid operation.*mismatched types"
_ = i == 1 // ERROR "invalid operation.*mismatched types|cannot convert"
_ = i != 1 // ERROR "invalid operation.*mismatched types|cannot convert"
_ = i >= 1 // ERROR "invalid operation.*mismatched types|cannot convert"
_ = 1 == i // ERROR "invalid operation.*mismatched types|cannot convert"
_ = 1 != i // ERROR "invalid operation.*mismatched types|cannot convert"
_ = 1 >= i // ERROR "invalid operation.*mismatched types|cannot convert"

_ = e == f // ERROR "invalid operation.*not defined"
_ = e != f // ERROR "invalid operation.*not defined"
Expand Down
2 changes: 1 addition & 1 deletion test/fixedbugs/issue9432.go
Expand Up @@ -9,7 +9,7 @@
// See golang.org/issue/9432.
package p

type foo struct { // ERROR "invalid recursive type"
type foo struct { // ERROR "invalid recursive type|cycle"
bar foo
blah foo
}
4 changes: 2 additions & 2 deletions test/fixedbugs/issue9521.go
Expand Up @@ -13,6 +13,6 @@ func f() (_, _ []int) { return }
func g() (x []int, y float64) { return }

func main() {
_ = append(f()) // ERROR "cannot use \[\]int value as type int in append"
_ = append(g()) // ERROR "cannot use float64 value as type int in append"
_ = append(f()) // ERROR "cannot use \[\]int value as type int in append|cannot use .* as int value"
_ = append(g()) // ERROR "cannot use float64 value as type int in append|cannot use .* as int value"
}
2 changes: 1 addition & 1 deletion test/fixedbugs/issue9634.go
Expand Up @@ -14,5 +14,5 @@ func main() {
t []int
u int
}{}
_ = append(s, 0) // ERROR "must be a slice|must be slice"
_ = append(s, 0) // ERROR "must be a slice|must be slice|not a slice"
}
2 changes: 1 addition & 1 deletion test/func1.go
Expand Up @@ -14,6 +14,6 @@ func f1(a int) (int, float32) {
}


func f2(a int) (a int, b float32) { // ERROR "duplicate argument a|definition"
func f2(a int) (a int, b float32) { // ERROR "duplicate argument a|definition|redeclared"
return 8, 8.0
}
24 changes: 12 additions & 12 deletions test/funcdup.go
Expand Up @@ -7,21 +7,21 @@
package p

type T interface {
F1(i int) (i int) // ERROR "duplicate argument i|redefinition|previous"
F2(i, i int) // ERROR "duplicate argument i|redefinition|previous"
F3() (i, i int) // ERROR "duplicate argument i|redefinition|previous"
F1(i int) (i int) // ERROR "duplicate argument i|redefinition|previous|redeclared"
F2(i, i int) // ERROR "duplicate argument i|redefinition|previous|redeclared"
F3() (i, i int) // ERROR "duplicate argument i|redefinition|previous|redeclared"
}

type T1 func(i, i int) // ERROR "duplicate argument i|redefinition|previous"
type T2 func(i int) (i int) // ERROR "duplicate argument i|redefinition|previous"
type T3 func() (i, i int) // ERROR "duplicate argument i|redefinition|previous"
type T1 func(i, i int) // ERROR "duplicate argument i|redefinition|previous|redeclared"
type T2 func(i int) (i int) // ERROR "duplicate argument i|redefinition|previous|redeclared"
type T3 func() (i, i int) // ERROR "duplicate argument i|redefinition|previous|redeclared"

type R struct{}

func (i *R) F1(i int) {} // ERROR "duplicate argument i|redefinition|previous"
func (i *R) F2() (i int) {return 0} // ERROR "duplicate argument i|redefinition|previous"
func (i *R) F3(j int) (j int) {return 0} // ERROR "duplicate argument j|redefinition|previous"
func (i *R) F1(i int) {} // ERROR "duplicate argument i|redefinition|previous|redeclared"
func (i *R) F2() (i int) {return 0} // ERROR "duplicate argument i|redefinition|previous|redeclared"
func (i *R) F3(j int) (j int) {return 0} // ERROR "duplicate argument j|redefinition|previous|redeclared"

func F1(i, i int) {} // ERROR "duplicate argument i|redefinition|previous"
func F2(i int) (i int) {return 0} // ERROR "duplicate argument i|redefinition|previous"
func F3() (i, i int) {return 0, 0} // ERROR "duplicate argument i|redefinition|previous"
func F1(i, i int) {} // ERROR "duplicate argument i|redefinition|previous|redeclared"
func F2(i int) (i int) {return 0} // ERROR "duplicate argument i|redefinition|previous|redeclared"
func F3() (i, i int) {return 0, 0} // ERROR "duplicate argument i|redefinition|previous|redeclared"
12 changes: 6 additions & 6 deletions test/funcdup2.go
Expand Up @@ -7,11 +7,11 @@
package p

var T interface {
F1(i int) (i int) // ERROR "duplicate argument i|redefinition|previous"
F2(i, i int) // ERROR "duplicate argument i|redefinition|previous"
F3() (i, i int) // ERROR "duplicate argument i|redefinition|previous"
F1(i int) (i int) // ERROR "duplicate argument i|redefinition|previous|redeclared"
F2(i, i int) // ERROR "duplicate argument i|redefinition|previous|redeclared"
F3() (i, i int) // ERROR "duplicate argument i|redefinition|previous|redeclared"
}

var T1 func(i, i int) // ERROR "duplicate argument i|redefinition|previous"
var T2 func(i int) (i int) // ERROR "duplicate argument i|redefinition|previous"
var T3 func() (i, i int) // ERROR "duplicate argument i|redefinition|previous"
var T1 func(i, i int) // ERROR "duplicate argument i|redefinition|previous|redeclared"
var T2 func(i int) (i int) // ERROR "duplicate argument i|redefinition|previous|redeclared"
var T3 func() (i, i int) // ERROR "duplicate argument i|redefinition|previous|redeclared"
2 changes: 1 addition & 1 deletion test/init.go
Expand Up @@ -14,6 +14,6 @@ func init() {

func main() {
init() // ERROR "undefined.*init"
runtime.init() // ERROR "undefined.*runtime\.init"
runtime.init() // ERROR "undefined.*runtime\.init|undefined: runtime"
var _ = init // ERROR "undefined.*init"
}
2 changes: 1 addition & 1 deletion test/initloop.go
Expand Up @@ -11,7 +11,7 @@ package main

var (
x int = a
a int = b // ERROR "a refers to\n.*b refers to\n.*c refers to\n.*a"
a int = b // ERROR "a refers to\n.*b refers to\n.*c refers to\n.*a|initialization cycle"
b int = c
c int = a
)
8 changes: 4 additions & 4 deletions test/makenew.go
Expand Up @@ -10,10 +10,10 @@
package main

func main() {
_ = make() // ERROR "missing argument"
_ = make(int) // ERROR "cannot make type"
_ = make([]int) // ERROR "missing len argument"
_ = make() // ERROR "missing argument|not enough arguments"
_ = make(int) // ERROR "cannot make type|cannot make int"
_ = make([]int) // ERROR "missing len argument|expects 2 or 3 arguments"

_ = new() // ERROR "missing argument"
_ = new() // ERROR "missing argument|not enough arguments"
_ = new(int, 2) // ERROR "too many arguments"
}
6 changes: 3 additions & 3 deletions test/map1.go
Expand Up @@ -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|is not a map"
}
6 changes: 3 additions & 3 deletions test/method2.go
Expand Up @@ -15,8 +15,8 @@ type T struct {
type P *T
type P1 *T

func (p P) val() int { return 1 } // ERROR "receiver.* pointer|invalid pointer or interface receiver"
func (p *P1) val() int { return 1 } // ERROR "receiver.* pointer|invalid pointer or interface receiver"
func (p P) val() int { return 1 } // ERROR "receiver.* pointer|invalid pointer or interface receiver|invalid receiver"
func (p *P1) val() int { return 1 } // ERROR "receiver.* pointer|invalid pointer or interface receiver|invalid receiver"

type I interface{}
type I1 interface{}
Expand All @@ -38,4 +38,4 @@ var _ = pv.val // ERROR "pv.val 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|cannot call pointer method"
2 changes: 1 addition & 1 deletion test/method6.go
Expand Up @@ -18,5 +18,5 @@ func (*B) g() {}

var _ = func() {
var a A
A(a).g() // ERROR "cannot call pointer method on|cannot take the address of"
A(a).g() // ERROR "cannot call pointer method .*on|cannot take the address of"
}
2 changes: 1 addition & 1 deletion test/named1.go
Expand Up @@ -54,7 +54,7 @@ func main() {
_ = b

_, bb := <-c
asBool(bb) // ERROR "cannot use.*type bool.*as type Bool"
asBool(bb) // ERROR "cannot use.*type bool.*as type Bool|cannot use bb"
_, b = <-c // ok now
_ = b

Expand Down
2 changes: 1 addition & 1 deletion test/rename1.go
Expand Up @@ -13,7 +13,7 @@ func main() {
var n byte // ERROR "not a type|expected type"
var y = float32(0) // ERROR "cannot call|expected function"
const (
a = 1 + iota // ERROR "invalid operation|incompatible types"
a = 1 + iota // ERROR "invalid operation|incompatible types|cannot convert"
)

}
Expand Down

0 comments on commit 02820d6

Please sign in to comment.