Skip to content

Commit 02820d6

Browse files
committed
[dev.typeparams] test: enable some more errorcheck tests
Change-Id: I103e3eeacd5b11efd63c965482a626878ba5ac81 Reviewed-on: https://go-review.googlesource.com/c/go/+/275216 Trust: Robert Griesemer <[email protected]> Run-TryBot: Robert Griesemer <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Robert Findley <[email protected]>
1 parent 9ff27e9 commit 02820d6

29 files changed

+100
-124
lines changed

test/copy1.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ func main() {
1717
_ = copy() // ERROR "not enough arguments"
1818
_ = copy(1, 2, 3) // ERROR "too many arguments"
1919

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

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

2727
}

test/fixedbugs/issue10975.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
package main
1111

1212
type I interface {
13-
int // ERROR "interface contains embedded non-interface int"
13+
int // ERROR "interface contains embedded non-interface int|not an interface"
1414
}
1515

1616
func New() I {

test/fixedbugs/issue11361.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66

77
package a
88

9-
import "fmt" // ERROR "imported and not used"
9+
import "fmt" // ERROR "imported and not used|imported but not used"
1010

11-
const n = fmt // ERROR "fmt without selector"
11+
const n = fmt // ERROR "fmt without selector|not in selector"

test/fixedbugs/issue11371.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
package issue11371
1111

12-
const a int = 1.1 // ERROR "constant 1.1 truncated to integer"
13-
const b int = 1e20 // ERROR "overflows int"
14-
const c int = 1 + 1e-100 // ERROR "constant truncated to integer"
15-
const d int = 1 - 1e-100 // ERROR "constant truncated to integer"
16-
const e int = 1.00000001 // ERROR "constant truncated to integer"
17-
const f int = 0.00000001 // ERROR "constant 1e-08 truncated to integer"
12+
const a int = 1.1 // ERROR "constant 1.1 truncated to integer|truncated to int"
13+
const b int = 1e20 // ERROR "overflows int|truncated to int"
14+
const c int = 1 + 1e-100 // ERROR "constant truncated to integer|truncated to int"
15+
const d int = 1 - 1e-100 // ERROR "constant truncated to integer|truncated to int"
16+
const e int = 1.00000001 // ERROR "constant truncated to integer|truncated to int"
17+
const f int = 0.00000001 // ERROR "constant 1e-08 truncated to integer|truncated to int"

test/fixedbugs/issue8385.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ func (t T) M(x int) {
2727
func g() func(int)
2828

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

3232
var i I
3333
var t *T
3434

3535
g()() // ERROR "not enough arguments in call to g\(\)"
3636
f() // ERROR "not enough arguments in call to f"
3737
i.M() // ERROR "not enough arguments in call to i\.M"
38-
I.M() // ERROR "not enough arguments in call to method expression I\.M"
38+
I.M() // ERROR "not enough arguments in call to method expression I\.M|not enough arguments in call"
3939
t.M() // ERROR "not enough arguments in call to t\.M"
40-
T.M() // ERROR "not enough arguments in call to method expression T\.M"
41-
(*T).M() // ERROR "not enough arguments in call to method expression \(\*T\)\.M"
40+
T.M() // ERROR "not enough arguments in call to method expression T\.M|not enough arguments in call"
41+
(*T).M() // ERROR "not enough arguments in call to method expression \(\*T\)\.M|not enough arguments in call"
4242
}

test/fixedbugs/issue8438.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
package main
1111

1212
func main() {
13-
_ = []byte{"foo"} // ERROR "cannot use"
14-
_ = []int{"foo"} // ERROR "cannot use"
15-
_ = []rune{"foo"} // ERROR "cannot use"
13+
_ = []byte{"foo"} // ERROR "cannot use|cannot convert"
14+
_ = []int{"foo"} // ERROR "cannot use|cannot convert"
15+
_ = []rune{"foo"} // ERROR "cannot use|cannot convert"
1616
_ = []string{"foo"} // OK
1717
}

test/fixedbugs/issue8440.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
package main
88

99
func main() {
10-
n.foo = 6 // ERROR "undefined: n in n.foo"
10+
n.foo = 6 // ERROR "undefined: n in n.foo|undefined: n"
1111
}

test/fixedbugs/issue8745.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
package p
1010

1111
func f(s string) {
12-
var _ float64 = s[2] // ERROR "cannot use.*type byte.*as type float64"
12+
var _ float64 = s[2] // ERROR "cannot use.*type byte.*as type float64|cannot use .* as float64 value"
1313
}

test/fixedbugs/issue9083.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const zero = 0
1313

1414
func main() {
1515
var x int
16+
_ = x
1617
x = make(map[int]int) // ERROR "cannot use make\(map\[int\]int\)|incompatible"
1718
x = make(map[int]int, 0) // ERROR "cannot use make\(map\[int\]int, 0\)|incompatible"
1819
x = make(map[int]int, zero) // ERROR "cannot use make\(map\[int\]int, zero\)|incompatible"

test/fixedbugs/issue9370.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ var (
6767
_ = 1 != e
6868
_ = 1 >= e // ERROR "invalid operation.*not defined"
6969

70-
_ = i == 1 // ERROR "invalid operation.*mismatched types"
71-
_ = i != 1 // ERROR "invalid operation.*mismatched types"
72-
_ = i >= 1 // ERROR "invalid operation.*mismatched types"
73-
_ = 1 == i // ERROR "invalid operation.*mismatched types"
74-
_ = 1 != i // ERROR "invalid operation.*mismatched types"
75-
_ = 1 >= i // ERROR "invalid operation.*mismatched types"
70+
_ = i == 1 // ERROR "invalid operation.*mismatched types|cannot convert"
71+
_ = i != 1 // ERROR "invalid operation.*mismatched types|cannot convert"
72+
_ = i >= 1 // ERROR "invalid operation.*mismatched types|cannot convert"
73+
_ = 1 == i // ERROR "invalid operation.*mismatched types|cannot convert"
74+
_ = 1 != i // ERROR "invalid operation.*mismatched types|cannot convert"
75+
_ = 1 >= i // ERROR "invalid operation.*mismatched types|cannot convert"
7676

7777
_ = e == f // ERROR "invalid operation.*not defined"
7878
_ = e != f // ERROR "invalid operation.*not defined"

test/fixedbugs/issue9432.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// See golang.org/issue/9432.
1010
package p
1111

12-
type foo struct { // ERROR "invalid recursive type"
12+
type foo struct { // ERROR "invalid recursive type|cycle"
1313
bar foo
1414
blah foo
1515
}

test/fixedbugs/issue9521.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ func f() (_, _ []int) { return }
1313
func g() (x []int, y float64) { return }
1414

1515
func main() {
16-
_ = append(f()) // ERROR "cannot use \[\]int value as type int in append"
17-
_ = append(g()) // ERROR "cannot use float64 value as type int in append"
16+
_ = append(f()) // ERROR "cannot use \[\]int value as type int in append|cannot use .* as int value"
17+
_ = append(g()) // ERROR "cannot use float64 value as type int in append|cannot use .* as int value"
1818
}

test/fixedbugs/issue9634.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ func main() {
1414
t []int
1515
u int
1616
}{}
17-
_ = append(s, 0) // ERROR "must be a slice|must be slice"
17+
_ = append(s, 0) // ERROR "must be a slice|must be slice|not a slice"
1818
}

test/func1.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ func f1(a int) (int, float32) {
1414
}
1515

1616

17-
func f2(a int) (a int, b float32) { // ERROR "duplicate argument a|definition"
17+
func f2(a int) (a int, b float32) { // ERROR "duplicate argument a|definition|redeclared"
1818
return 8, 8.0
1919
}

test/funcdup.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@
77
package p
88

99
type T interface {
10-
F1(i int) (i int) // ERROR "duplicate argument i|redefinition|previous"
11-
F2(i, i int) // ERROR "duplicate argument i|redefinition|previous"
12-
F3() (i, i int) // ERROR "duplicate argument i|redefinition|previous"
10+
F1(i int) (i int) // ERROR "duplicate argument i|redefinition|previous|redeclared"
11+
F2(i, i int) // ERROR "duplicate argument i|redefinition|previous|redeclared"
12+
F3() (i, i int) // ERROR "duplicate argument i|redefinition|previous|redeclared"
1313
}
1414

15-
type T1 func(i, i int) // ERROR "duplicate argument i|redefinition|previous"
16-
type T2 func(i int) (i int) // ERROR "duplicate argument i|redefinition|previous"
17-
type T3 func() (i, i int) // ERROR "duplicate argument i|redefinition|previous"
15+
type T1 func(i, i int) // ERROR "duplicate argument i|redefinition|previous|redeclared"
16+
type T2 func(i int) (i int) // ERROR "duplicate argument i|redefinition|previous|redeclared"
17+
type T3 func() (i, i int) // ERROR "duplicate argument i|redefinition|previous|redeclared"
1818

1919
type R struct{}
2020

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

25-
func F1(i, i int) {} // ERROR "duplicate argument i|redefinition|previous"
26-
func F2(i int) (i int) {return 0} // ERROR "duplicate argument i|redefinition|previous"
27-
func F3() (i, i int) {return 0, 0} // ERROR "duplicate argument i|redefinition|previous"
25+
func F1(i, i int) {} // ERROR "duplicate argument i|redefinition|previous|redeclared"
26+
func F2(i int) (i int) {return 0} // ERROR "duplicate argument i|redefinition|previous|redeclared"
27+
func F3() (i, i int) {return 0, 0} // ERROR "duplicate argument i|redefinition|previous|redeclared"

test/funcdup2.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
package p
88

99
var T interface {
10-
F1(i int) (i int) // ERROR "duplicate argument i|redefinition|previous"
11-
F2(i, i int) // ERROR "duplicate argument i|redefinition|previous"
12-
F3() (i, i int) // ERROR "duplicate argument i|redefinition|previous"
10+
F1(i int) (i int) // ERROR "duplicate argument i|redefinition|previous|redeclared"
11+
F2(i, i int) // ERROR "duplicate argument i|redefinition|previous|redeclared"
12+
F3() (i, i int) // ERROR "duplicate argument i|redefinition|previous|redeclared"
1313
}
1414

15-
var T1 func(i, i int) // ERROR "duplicate argument i|redefinition|previous"
16-
var T2 func(i int) (i int) // ERROR "duplicate argument i|redefinition|previous"
17-
var T3 func() (i, i int) // ERROR "duplicate argument i|redefinition|previous"
15+
var T1 func(i, i int) // ERROR "duplicate argument i|redefinition|previous|redeclared"
16+
var T2 func(i int) (i int) // ERROR "duplicate argument i|redefinition|previous|redeclared"
17+
var T3 func() (i, i int) // ERROR "duplicate argument i|redefinition|previous|redeclared"

test/init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ func init() {
1414

1515
func main() {
1616
init() // ERROR "undefined.*init"
17-
runtime.init() // ERROR "undefined.*runtime\.init"
17+
runtime.init() // ERROR "undefined.*runtime\.init|undefined: runtime"
1818
var _ = init // ERROR "undefined.*init"
1919
}

test/initloop.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ package main
1111

1212
var (
1313
x int = a
14-
a int = b // ERROR "a refers to\n.*b refers to\n.*c refers to\n.*a"
14+
a int = b // ERROR "a refers to\n.*b refers to\n.*c refers to\n.*a|initialization cycle"
1515
b int = c
1616
c int = a
1717
)

test/makenew.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
package main
1111

1212
func main() {
13-
_ = make() // ERROR "missing argument"
14-
_ = make(int) // ERROR "cannot make type"
15-
_ = make([]int) // ERROR "missing len argument"
13+
_ = make() // ERROR "missing argument|not enough arguments"
14+
_ = make(int) // ERROR "cannot make type|cannot make int"
15+
_ = make([]int) // ERROR "missing len argument|expects 2 or 3 arguments"
1616

17-
_ = new() // ERROR "missing argument"
17+
_ = new() // ERROR "missing argument|not enough arguments"
1818
_ = new(int, 2) // ERROR "too many arguments"
1919
}

test/map1.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ type T8 struct { F *T7 }
6161

6262
func main() {
6363
m := make(map[int]int)
64-
delete() // ERROR "missing arguments"
65-
delete(m) // ERROR "missing second \(key\) argument"
64+
delete() // ERROR "missing arguments|not enough arguments"
65+
delete(m) // ERROR "missing second \(key\) argument|not enough arguments"
6666
delete(m, 2, 3) // ERROR "too many arguments"
67-
delete(1, m) // ERROR "first argument to delete must be map"
67+
delete(1, m) // ERROR "first argument to delete must be map|is not a map"
6868
}

test/method2.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ type T struct {
1515
type P *T
1616
type P1 *T
1717

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

2121
type I interface{}
2222
type I1 interface{}
@@ -38,4 +38,4 @@ var _ = pv.val // ERROR "pv.val undefined"
3838

3939
func (t *T) g() int { return t.a }
4040

41-
var _ = (T).g() // ERROR "needs pointer receiver|undefined"
41+
var _ = (T).g() // ERROR "needs pointer receiver|undefined|cannot call pointer method"

test/method6.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ func (*B) g() {}
1818

1919
var _ = func() {
2020
var a A
21-
A(a).g() // ERROR "cannot call pointer method on|cannot take the address of"
21+
A(a).g() // ERROR "cannot call pointer method .*on|cannot take the address of"
2222
}

test/named1.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func main() {
5454
_ = b
5555

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

test/rename1.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func main() {
1313
var n byte // ERROR "not a type|expected type"
1414
var y = float32(0) // ERROR "cannot call|expected function"
1515
const (
16-
a = 1 + iota // ERROR "invalid operation|incompatible types"
16+
a = 1 + iota // ERROR "invalid operation|incompatible types|cannot convert"
1717
)
1818

1919
}

0 commit comments

Comments
 (0)