mirror of
https://github.com/golang/go
synced 2024-11-16 20:54:48 -07:00
go/types, types2: consolidate testdata/fixedbugs test files
Use the go/types version of testdata/fixedbugs tests where diffs are only in the error positions (the types2 test harness allows for some position tolerance). Consolidate files where there are other minor differences. Add files to respective directories if they only existed for one of the type checkers. Move types2-only test issue47996.go out of testdata/fixedbugs into testdata. Making it work for both type checkers requires some more work. With this CL, the testdata/fixedbugs files are identical between the two type checkers. For #54511. Change-Id: I0d67f0db75ad1743c62da9181a6d0032c8bdb728 Reviewed-on: https://go-review.googlesource.com/c/go/+/427236 Reviewed-by: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
parent
1be8fcdcdc
commit
9649a4119c
@ -303,7 +303,7 @@ func TestCheck(t *testing.T) {
|
||||
}
|
||||
func TestSpec(t *testing.T) { testDirFiles(t, "../../../../go/types/testdata/spec", 0, false) }
|
||||
func TestExamples(t *testing.T) { testDirFiles(t, "../../../../go/types/testdata/examples", 45, false) } // TODO(gri) narrow column tolerance
|
||||
func TestFixedbugs(t *testing.T) { testDirFiles(t, "testdata/fixedbugs", 0, false) }
|
||||
func TestFixedbugs(t *testing.T) { testDirFiles(t, "testdata/fixedbugs", 100, false) } // TODO(gri) narrow column tolerance
|
||||
|
||||
func testDirFiles(t *testing.T, dir string, colDelta uint, manual bool) {
|
||||
testenv.MustHaveGoBuild(t)
|
||||
|
@ -3,10 +3,12 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package issue20583
|
||||
|
||||
const (
|
||||
_ = 6e886451608 /* ERROR malformed constant */ /2
|
||||
_ = 6e886451608i /* ERROR malformed constant */ /2
|
||||
_ = 0 * 1e+1000000000 // ERROR malformed constant
|
||||
|
||||
x = 1e100000000
|
||||
_ = x*x*x*x*x*x* /* ERROR not representable */ x
|
||||
)
|
||||
|
@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// stand-alone test to ensure case is triggered
|
||||
|
||||
package issue26390
|
||||
|
||||
type A = T
|
||||
|
@ -87,4 +87,4 @@ func F26[Z any]() T26 { return F26[] /* ERROR operand */ }
|
||||
|
||||
// crash 27
|
||||
func e27[T any]() interface{ x27 /* ERROR not a type */ } { panic(0) }
|
||||
func x27() { e27( /* ERROR cannot infer T */ ) }
|
||||
func x27() { e27 /* ERROR cannot infer T */ () }
|
||||
|
@ -15,7 +15,7 @@ func Add1[T Number1](a, b T) T {
|
||||
}
|
||||
|
||||
type Number2 interface {
|
||||
int|float64
|
||||
int | float64
|
||||
}
|
||||
|
||||
func Add2[T Number2](a, b T) T {
|
||||
|
@ -7,7 +7,7 @@ package p
|
||||
// Do not report a duplicate type error for this term list.
|
||||
// (Check types after interfaces have been completed.)
|
||||
type _ interface {
|
||||
// TODO(gri) Once we have full type sets we can enable this again.
|
||||
// TODO(rfindley) Once we have full type sets we can enable this again.
|
||||
// Fow now we don't permit interfaces in term lists.
|
||||
// type interface{ Error() string }, interface{ String() string }
|
||||
}
|
||||
|
@ -12,4 +12,4 @@ func f[P interface{m(P)}]() {}
|
||||
|
||||
func _() {
|
||||
_ = f[A[int]]
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
package p
|
||||
|
||||
func _() {
|
||||
NewS( /* ERROR cannot infer T */ ) .M()
|
||||
NewS /* ERROR cannot infer T */ ().M()
|
||||
}
|
||||
|
||||
type S struct {}
|
||||
|
@ -12,4 +12,4 @@ func g[_, _ any]() {}
|
||||
func _() {
|
||||
_ = f[T /* ERROR without instantiation */ ]
|
||||
_ = g[T /* ERROR without instantiation */ , T /* ERROR without instantiation */ ]
|
||||
}
|
||||
}
|
||||
|
@ -5,4 +5,4 @@
|
||||
// Check that there is only one error (no follow-on errors).
|
||||
|
||||
package p
|
||||
var _ = [ /* ERROR invalid use of .* array */ ...]byte("foo")
|
||||
var _ = [ ... /* ERROR invalid use of \[...\] array */ ]byte("foo")
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2020 The Go Authors. All rights reserved.
|
||||
// Copyright 2021 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
|
@ -10,7 +10,7 @@ func main() {
|
||||
|
||||
type N[T any] struct{}
|
||||
|
||||
var _ N[] /* ERROR expected type */
|
||||
var _ N [] // ERROR expected type argument list
|
||||
|
||||
type I interface {
|
||||
~[]int
|
||||
@ -18,14 +18,14 @@ type I interface {
|
||||
|
||||
func _[T I](i, j int) {
|
||||
var m map[int]int
|
||||
_ = m[i, j /* ERROR more than one index */ ]
|
||||
_ = m[i, j /* ERROR "more than one index" */ ]
|
||||
|
||||
var a [3]int
|
||||
_ = a[i, j /* ERROR more than one index */ ]
|
||||
_ = a[i, j /* ERROR "more than one index" */ ]
|
||||
|
||||
var s []int
|
||||
_ = s[i, j /* ERROR more than one index */ ]
|
||||
_ = s[i, j /* ERROR "more than one index" */ ]
|
||||
|
||||
var t T
|
||||
_ = t[i, j /* ERROR more than one index */ ]
|
||||
_ = t[i, j /* ERROR "more than one index" */ ]
|
||||
}
|
||||
|
@ -8,10 +8,10 @@ func f1[T any, C chan T | <-chan T](ch C) {}
|
||||
|
||||
func _(ch chan int) { f1(ch) }
|
||||
func _(ch <-chan int) { f1(ch) }
|
||||
func _(ch chan<- int) { f1( /* ERROR chan<- int does not implement chan int\|<-chan int */ ch) }
|
||||
func _(ch chan<- int) { f1 /* ERROR chan<- int does not implement chan int\|<-chan int */ (ch) }
|
||||
|
||||
func f2[T any, C chan T | chan<- T](ch C) {}
|
||||
|
||||
func _(ch chan int) { f2(ch) }
|
||||
func _(ch <-chan int) { f2( /* ERROR <-chan int does not implement chan int\|chan<- int */ ch) }
|
||||
func _(ch <-chan int) { f2 /* ERROR <-chan int does not implement chan int\|chan<- int */ (ch) }
|
||||
func _(ch chan<- int) { f2(ch) }
|
||||
|
@ -9,5 +9,5 @@ func app[S interface{ ~[]T }, T any](s S, e T) S {
|
||||
}
|
||||
|
||||
func _() {
|
||||
_ = app[/* ERROR "S does not match" */int]
|
||||
_ = app/* ERROR "S does not match" */[int]
|
||||
}
|
||||
|
@ -5,22 +5,22 @@
|
||||
package issue46275
|
||||
|
||||
type N[T any] struct {
|
||||
*N[T]
|
||||
t T
|
||||
*N[T]
|
||||
t T
|
||||
}
|
||||
|
||||
func (n *N[T]) Elem() T {
|
||||
return n.t
|
||||
return n.t
|
||||
}
|
||||
|
||||
type I interface {
|
||||
Elem() string
|
||||
Elem() string
|
||||
}
|
||||
|
||||
func _() {
|
||||
var n1 *N[string]
|
||||
var _ I = n1
|
||||
type NS N[string]
|
||||
var n2 *NS
|
||||
var _ I = n2
|
||||
var n1 *N[string]
|
||||
var _ I = n1
|
||||
type NS N[string]
|
||||
var n2 *NS
|
||||
var _ I = n2
|
||||
}
|
||||
|
11
src/cmd/compile/internal/types2/testdata/fixedbugs/issue46403.go
vendored
Normal file
11
src/cmd/compile/internal/types2/testdata/fixedbugs/issue46403.go
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
// Copyright 2021 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package issue46403
|
||||
|
||||
func _() {
|
||||
// a should be used, despite the parser error below.
|
||||
var a []int
|
||||
var _ = a[] // ERROR expected operand
|
||||
}
|
@ -12,11 +12,11 @@ type C4 interface{ chan int | chan<- int }
|
||||
type C5[T any] interface{ ~chan T | chan<- T }
|
||||
|
||||
func _[T any](ch T) {
|
||||
ch /* ERROR cannot send to ch .* no core type */ <- 0
|
||||
ch <- /* ERROR cannot send to ch .* no core type */ 0
|
||||
}
|
||||
|
||||
func _[T C0](ch T) {
|
||||
ch /* ERROR cannot send to non-channel */ <- 0
|
||||
ch <- /* ERROR cannot send to non-channel */ 0
|
||||
}
|
||||
|
||||
func _[T C1](ch T) {
|
||||
@ -24,11 +24,11 @@ func _[T C1](ch T) {
|
||||
}
|
||||
|
||||
func _[T C2](ch T) {
|
||||
ch /* ERROR cannot send to receive-only channel */ <- 0
|
||||
ch <-/* ERROR cannot send to receive-only channel */ 0
|
||||
}
|
||||
|
||||
func _[T C3](ch T) {
|
||||
ch /* ERROR cannot send to ch .* no core type */ <- 0
|
||||
ch <- /* ERROR cannot send to ch .* no core type */ 0
|
||||
}
|
||||
|
||||
func _[T C4](ch T) {
|
||||
|
@ -15,12 +15,12 @@ func _[P comparable,
|
||||
_ = f[int]
|
||||
_ = f[P]
|
||||
_ = f[Q]
|
||||
_ = f[func( /* ERROR does not implement comparable */ )]
|
||||
_ = f[func /* ERROR does not implement comparable */ ()]
|
||||
_ = f[R /* ERROR R does not implement comparable */ ]
|
||||
|
||||
_ = g[int]
|
||||
_ = g[P /* ERROR P does not implement interface{interface{comparable; ~int\|~string} */ ]
|
||||
_ = g[Q]
|
||||
_ = g[func( /* ERROR func\(\) does not implement interface{interface{comparable; ~int\|~string}} */ )]
|
||||
_ = g[func /* ERROR func\(\) does not implement interface{interface{comparable; ~int\|~string}} */ ()]
|
||||
_ = g[R /* ERROR R does not implement interface{interface{comparable; ~int\|~string} */ ]
|
||||
}
|
||||
|
@ -12,12 +12,12 @@ func f5[P interface{ func(P) }]() {}
|
||||
func f6[P interface { *Tree[P] }, Q any ]() {}
|
||||
|
||||
func _() {
|
||||
f1( /* ERROR cannot infer P */ )
|
||||
f2( /* ERROR cannot infer P */ )
|
||||
f3( /* ERROR cannot infer P */ )
|
||||
f4( /* ERROR cannot infer P */ )
|
||||
f5( /* ERROR cannot infer P */ )
|
||||
f6( /* ERROR cannot infer P */ )
|
||||
f1 /* ERROR cannot infer P */ ()
|
||||
f2 /* ERROR cannot infer P */ ()
|
||||
f3 /* ERROR cannot infer P */ ()
|
||||
f4 /* ERROR cannot infer P */ ()
|
||||
f5 /* ERROR cannot infer P */ ()
|
||||
f6 /* ERROR cannot infer P */ ()
|
||||
}
|
||||
|
||||
type Tree[P any] struct {
|
||||
@ -32,5 +32,5 @@ func foo[Src interface { func() Src }]() Src {
|
||||
}
|
||||
|
||||
func _() {
|
||||
foo( /* ERROR cannot infer Src */ )
|
||||
foo /* ERROR cannot infer Src */ ()
|
||||
}
|
||||
|
@ -15,5 +15,5 @@ type (
|
||||
|
||||
// The example from the issue.
|
||||
func _() {
|
||||
_ = &([10]bool /* ERROR "invalid operation.*bool is not a generic type" */ [1 /* ERROR expected type */ ]{})
|
||||
_ = &([10]bool /* ERROR "invalid operation.*bool is not a generic type" */ [1 /* ERROR "expected type" */ ]{})
|
||||
}
|
||||
|
@ -11,5 +11,5 @@ func _() {
|
||||
_ = f[[ /* ERROR \[\]int does not implement int */ ]int]
|
||||
|
||||
f(0)
|
||||
f( /* ERROR \[\]int does not implement int */ []int{})
|
||||
f/* ERROR \[\]int does not implement int */ ([]int{})
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ func _() {
|
||||
_ = f2[myInt]
|
||||
_ = f2[myFloat /* ERROR possibly missing ~ for float64 in constraint int\|string|float64 */]
|
||||
var x myInt
|
||||
f3( /* ERROR myInt does not implement int \(possibly missing ~ for int in constraint int\) */ x)
|
||||
f3 /* ERROR myInt does not implement int \(possibly missing ~ for int in constraint int\) */ (x)
|
||||
}
|
||||
|
||||
// test case from the issue
|
||||
|
@ -5,15 +5,15 @@
|
||||
package p
|
||||
|
||||
type M interface {
|
||||
m()
|
||||
m()
|
||||
}
|
||||
|
||||
type C interface {
|
||||
comparable
|
||||
comparable
|
||||
}
|
||||
|
||||
type _ interface{
|
||||
int | M // ERROR cannot use p\.M in union \(p\.M contains methods\)
|
||||
int | comparable // ERROR cannot use comparable in union
|
||||
int | C // ERROR cannot use p\.C in union \(p\.C embeds comparable\)
|
||||
type _ interface {
|
||||
int | M // ERROR cannot use p\.M in union \(p\.M contains methods\)
|
||||
int | comparable // ERROR cannot use comparable in union
|
||||
int | C // ERROR cannot use p\.C in union \(p\.C embeds comparable\)
|
||||
}
|
||||
|
@ -11,8 +11,8 @@ func _(s []int) {
|
||||
for range s {}
|
||||
for i = range s {}
|
||||
for i, j = range s {}
|
||||
for i, j, k /* ERROR range clause permits at most two iteration variables */ = range s {}
|
||||
for i, j, k /* ERROR range clause permits at most two iteration variables */, l = range s {}
|
||||
for i, j, k /* ERROR range clause permits at most two iteration variables|at most 2 expressions */ = range s {}
|
||||
for i, j, k, l /* ERROR range clause permits at most two iteration variables|at most 2 expressions */ = range s {}
|
||||
}
|
||||
|
||||
func _(s chan int) {
|
||||
@ -22,6 +22,6 @@ func _(s chan int) {
|
||||
for range s {}
|
||||
for i = range s {}
|
||||
for i, j /* ERROR range over .* permits only one iteration variable */ = range s {}
|
||||
for i, j /* ERROR range over .* permits only one iteration variable */, k = range s {}
|
||||
for i, j /* ERROR range over .* permits only one iteration variable */, k, l = range s {}
|
||||
for i, j, k /* ERROR range over .* permits only one iteration variable|at most 2 expressions */ = range s {}
|
||||
for i, j, k, l /* ERROR range over .* permits only one iteration variable|at most 2 expressions */ = range s {}
|
||||
}
|
||||
|
23
src/cmd/compile/internal/types2/testdata/fixedbugs/issue50427.go
vendored
Normal file
23
src/cmd/compile/internal/types2/testdata/fixedbugs/issue50427.go
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright 2022 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package p
|
||||
|
||||
// The parser no longer parses type parameters for methods.
|
||||
// In the past, type checking the code below led to a crash (#50427).
|
||||
|
||||
type T interface{ m[ /* ERROR "must have no type parameters" */ P any]() }
|
||||
|
||||
func _(t T) {
|
||||
var _ interface{ m[ /* ERROR "must have no type parameters" */ P any](); n() } = t /* ERROR "does not implement" */
|
||||
}
|
||||
|
||||
type S struct{}
|
||||
|
||||
func (S) m[ /* ERROR "must have no type parameters" */ P any]() {}
|
||||
|
||||
func _(s S) {
|
||||
var _ interface{ m[ /* ERROR "must have no type parameters" */ P any](); n() } = s /* ERROR "does not implement" */
|
||||
|
||||
}
|
@ -109,7 +109,7 @@ func _() {
|
||||
var _ chan<- int = ch1()
|
||||
|
||||
// P cannot be inferred as there's a tilde.
|
||||
ch2( /* ERROR cannot infer P */ )
|
||||
ch2 /* ERROR cannot infer P */ ()
|
||||
type myChan chan int
|
||||
ch2[myChan]()
|
||||
|
||||
@ -118,11 +118,11 @@ func _() {
|
||||
ch3(e)
|
||||
|
||||
// P cannot be inferred as there's more than one specific type and a tilde.
|
||||
ch4( /* ERROR cannot infer P */ e)
|
||||
ch4 /* ERROR cannot infer P */ (e)
|
||||
_ = ch4[chan int]
|
||||
|
||||
// P cannot be inferred as there's more than one specific type.
|
||||
ch5( /* ERROR cannot infer P */ )
|
||||
ch5 /* ERROR cannot infer P */ ()
|
||||
ch5[chan<- int]()
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ func NewSetFromSlice[T comparable](items []T) *Set[T] {
|
||||
type T struct{ x any }
|
||||
|
||||
func main() {
|
||||
NewSetFromSlice( /* ERROR T does not implement comparable */ []T{
|
||||
NewSetFromSlice /* ERROR T does not implement comparable */ ([]T{
|
||||
{"foo"},
|
||||
{5},
|
||||
})
|
||||
|
@ -12,7 +12,7 @@ type T[P any, B *P] struct{}
|
||||
func (T /* ERROR cannot use generic type */ ) m0() {}
|
||||
|
||||
// TODO(rfindley): eliminate the duplicate errors here.
|
||||
func (T /* ERROR got 1 type parameter, but receiver base type declares 2 */ /* ERROR got 1 arguments but 2 type parameters */ [_]) m1() {}
|
||||
func (/* ERROR got 1 type parameter, but receiver base type declares 2 */ T /* ERROR got 1 arguments but 2 type parameters */ [_]) m1() {}
|
||||
func (T[_, _]) m2() {}
|
||||
// TODO(gri) this error is unfortunate (issue #51343)
|
||||
func (T /* ERROR got 3 arguments but 2 type parameters */ [_, _, _]) m3() {}
|
||||
|
@ -5,9 +5,9 @@
|
||||
package p
|
||||
|
||||
func _() {
|
||||
len. /* ERROR cannot select on len */ Println
|
||||
len. /* ERROR cannot select on len */ Println()
|
||||
_ = len. /* ERROR cannot select on len */ Println
|
||||
_ = len[ /* ERROR cannot index len */ 0]
|
||||
len.Println /* ERROR cannot select on len */
|
||||
len.Println /* ERROR cannot select on len */ ()
|
||||
_ = len.Println /* ERROR cannot select on len */
|
||||
_ = len /* ERROR cannot index len */ [0]
|
||||
_ = *len /* ERROR cannot indirect len */
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ func g[M map[K]V, K comparable, V any](M) {}
|
||||
func _[M1 ~map[K]V, M2 map[K]V, K comparable, V any]() {
|
||||
var m1 M1
|
||||
f(m1)
|
||||
g( /* ERROR M1 does not implement map\[K\]V */ m1) // M1 has tilde
|
||||
g /* ERROR M1 does not implement map\[K\]V */ (m1) // M1 has tilde
|
||||
|
||||
var m2 M2
|
||||
f(m2)
|
||||
@ -20,5 +20,5 @@ func _[M1 ~map[K]V, M2 map[K]V, K comparable, V any]() {
|
||||
|
||||
var m3 Map
|
||||
f(m3)
|
||||
g( /* ERROR Map does not implement map\[string\]int */ m3) // M in g does not have tilde
|
||||
g /* ERROR Map does not implement map\[string\]int */ (m3) // M in g does not have tilde
|
||||
}
|
||||
|
@ -49,6 +49,6 @@ func f[T interface{comparable; []byte|string}](x T) {
|
||||
}
|
||||
|
||||
func _(s []byte) {
|
||||
f( /* ERROR \[\]byte does not implement interface{comparable; \[\]byte\|string} */ s)
|
||||
f /* ERROR \[\]byte does not implement interface{comparable; \[\]byte\|string} */ (s)
|
||||
_ = f[[ /* ERROR does not implement */ ]byte]
|
||||
}
|
||||
|
@ -9,5 +9,5 @@ func f[P interface{ m(R) }, R any]() {}
|
||||
type T = interface { m(int) }
|
||||
|
||||
func _() {
|
||||
_ = f[ /* ERROR cannot infer R */ T] // don't crash in type inference
|
||||
_ = f /* ERROR cannot infer R */ [T] // don't crash in type inference
|
||||
}
|
||||
|
@ -10,12 +10,12 @@ type Number1 interface {
|
||||
float64
|
||||
}
|
||||
|
||||
func Add[T Number1](a, b T) T {
|
||||
func Add1[T Number1](a, b T) T {
|
||||
return a /* ERROR not defined */ + b
|
||||
}
|
||||
|
||||
type Number2 interface {
|
||||
int|float64
|
||||
int | float64
|
||||
}
|
||||
|
||||
func Add2[T Number2](a, b T) T {
|
||||
|
19
src/go/types/testdata/fixedbugs/issue46275.go
vendored
19
src/go/types/testdata/fixedbugs/issue46275.go
vendored
@ -5,23 +5,22 @@
|
||||
package issue46275
|
||||
|
||||
type N[T any] struct {
|
||||
*N[T]
|
||||
t T
|
||||
*N[T]
|
||||
t T
|
||||
}
|
||||
|
||||
func (n *N[T]) Elem() T {
|
||||
return n.t
|
||||
return n.t
|
||||
}
|
||||
|
||||
type I interface {
|
||||
Elem() string
|
||||
Elem() string
|
||||
}
|
||||
|
||||
func _() {
|
||||
var n1 *N[string]
|
||||
var _ I = n1
|
||||
type NS N[string]
|
||||
var n2 *NS
|
||||
var _ I = n2
|
||||
var n1 *N[string]
|
||||
var _ I = n1
|
||||
type NS N[string]
|
||||
var n2 *NS
|
||||
var _ I = n2
|
||||
}
|
||||
|
||||
|
28
src/go/types/testdata/fixedbugs/issue46583.go
vendored
Normal file
28
src/go/types/testdata/fixedbugs/issue46583.go
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright 2021 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package p
|
||||
|
||||
type T1 struct{}
|
||||
func (t T1) m(int) {}
|
||||
var f1 func(T1)
|
||||
|
||||
type T2 struct{}
|
||||
func (t T2) m(x int) {}
|
||||
var f2 func(T2)
|
||||
|
||||
type T3 struct{}
|
||||
func (T3) m(int) {}
|
||||
var f3 func(T3)
|
||||
|
||||
type T4 struct{}
|
||||
func (T4) m(x int) {}
|
||||
var f4 func(T4)
|
||||
|
||||
func _() {
|
||||
f1 = T1 /* ERROR func\(T1, int\) */ .m
|
||||
f2 = T2 /* ERROR func\(t T2, x int\) */ .m
|
||||
f3 = T3 /* ERROR func\(T3, int\) */ .m
|
||||
f4 = T4 /* ERROR func\(_ T4, x int\) */ .m
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
|
||||
package p
|
||||
|
||||
func g[P interface{~func(T) P}, T any](P) {}
|
||||
func g[P ~func(T) P, T any](P) {}
|
||||
|
||||
func _() {
|
||||
type F func(int) F
|
||||
|
@ -9,7 +9,6 @@ func _[
|
||||
T1 []int,
|
||||
T2 ~float64 | ~complex128 | chan int,
|
||||
]() {
|
||||
// TODO(rfindley): the types2 error here is clearer.
|
||||
_ = T0(nil /* ERROR cannot convert nil to T0 */ )
|
||||
_ = T1(1 /* ERROR cannot convert 1 .* to T1 */ )
|
||||
_ = T2(2 /* ERROR cannot convert 2 .* to T2 */ )
|
||||
|
27
src/go/types/testdata/fixedbugs/issue50372.go
vendored
Normal file
27
src/go/types/testdata/fixedbugs/issue50372.go
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright 2021 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package p
|
||||
|
||||
func _(s []int) {
|
||||
var i, j, k, l int
|
||||
_, _, _, _ = i, j, k, l
|
||||
|
||||
for range s {}
|
||||
for i = range s {}
|
||||
for i, j = range s {}
|
||||
for i, j, k /* ERROR range clause permits at most two iteration variables|at most 2 expressions */ = range s {}
|
||||
for i, j, k, l /* ERROR range clause permits at most two iteration variables|at most 2 expressions */ = range s {}
|
||||
}
|
||||
|
||||
func _(s chan int) {
|
||||
var i, j, k, l int
|
||||
_, _, _, _ = i, j, k, l
|
||||
|
||||
for range s {}
|
||||
for i = range s {}
|
||||
for i, j /* ERROR range over .* permits only one iteration variable */ = range s {}
|
||||
for i, j, k /* ERROR range over .* permits only one iteration variable|at most 2 expressions */ = range s {}
|
||||
for i, j, k, l /* ERROR range over .* permits only one iteration variable|at most 2 expressions */ = range s {}
|
||||
}
|
28
src/go/types/testdata/fixedbugs/issue52698.go
vendored
28
src/go/types/testdata/fixedbugs/issue52698.go
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
package p
|
||||
|
||||
// sanity check
|
||||
// correctness check: ensure that cycles through generic instantiations are detected
|
||||
type T[P any] struct {
|
||||
_ P
|
||||
}
|
||||
@ -13,18 +13,30 @@ type S /* ERROR illegal cycle */ struct {
|
||||
_ T[S]
|
||||
}
|
||||
|
||||
// simplified test
|
||||
var _ B[A]
|
||||
// simplified test 1
|
||||
|
||||
type A struct {
|
||||
_ B[string]
|
||||
var _ A1[A1[string]]
|
||||
|
||||
type A1[P any] struct {
|
||||
_ B1[P]
|
||||
}
|
||||
|
||||
type B[P any] struct {
|
||||
_ C[P]
|
||||
type B1[P any] struct {
|
||||
_ P
|
||||
}
|
||||
|
||||
type C[P any] struct {
|
||||
// simplified test 2
|
||||
var _ B2[A2]
|
||||
|
||||
type A2 struct {
|
||||
_ B2[string]
|
||||
}
|
||||
|
||||
type B2[P any] struct {
|
||||
_ C2[P]
|
||||
}
|
||||
|
||||
type C2[P any] struct {
|
||||
_ P
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user