mirror of
https://github.com/golang/go
synced 2024-09-24 07:20:14 -06:00
[dev.typeparams] test: add regress tests that fail(ed) with -G=3
This CL includes multiple test cases that exercise unique failures with -G=3 mode that did not affect unified IR mode. Most of these were found over a period of about 3 hours of manual experimentation. Thanks to Cuong Manh Le for test cases 11 and 12. Updates #46704. Change-Id: Ia2fa619536732b121b6c929329065c85b9384511 Reviewed-on: https://go-review.googlesource.com/c/go/+/326169 Trust: Matthew Dempsky <mdempsky@google.com> Trust: Dan Scales <danscales@google.com> Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com> Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
49ade6b298
commit
5c42b6a953
15
test/run.go
15
test/run.go
@ -86,7 +86,7 @@ var (
|
||||
|
||||
// dirs are the directories to look for *.go files in.
|
||||
// TODO(bradfitz): just use all directories?
|
||||
dirs = []string{".", "ken", "chan", "interface", "syntax", "dwarf", "fixedbugs", "codegen", "runtime", "abi", "typeparam"}
|
||||
dirs = []string{".", "ken", "chan", "interface", "syntax", "dwarf", "fixedbugs", "codegen", "runtime", "abi", "typeparam", "typeparam/mdempsky"}
|
||||
|
||||
// ratec controls the max number of tests running at a time.
|
||||
ratec chan bool
|
||||
@ -2203,6 +2203,19 @@ var g3Failures = setOf(
|
||||
"fixedbugs/issue9691.go", // "cannot assign to int(.autotmp_4)" (probably irgen's fault)
|
||||
|
||||
"typeparam/nested.go", // -G=3 doesn't support function-local types with generics
|
||||
|
||||
"typeparam/mdempsky/1.go",
|
||||
"typeparam/mdempsky/2.go",
|
||||
"typeparam/mdempsky/3.go",
|
||||
"typeparam/mdempsky/4.go",
|
||||
"typeparam/mdempsky/5.go",
|
||||
"typeparam/mdempsky/7.go",
|
||||
"typeparam/mdempsky/8.go",
|
||||
"typeparam/mdempsky/9.go",
|
||||
"typeparam/mdempsky/11.go",
|
||||
"typeparam/mdempsky/12.go",
|
||||
"typeparam/mdempsky/13.go",
|
||||
"typeparam/mdempsky/14.go",
|
||||
)
|
||||
|
||||
var unifiedFailures = setOf(
|
||||
|
9
test/typeparam/mdempsky/1.dir/a.go
Normal file
9
test/typeparam/mdempsky/1.dir/a.go
Normal file
@ -0,0 +1,9 @@
|
||||
// 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 a
|
||||
|
||||
type T[_ any] int
|
||||
|
||||
func F() { _ = new(T[int]) }
|
9
test/typeparam/mdempsky/1.dir/b.go
Normal file
9
test/typeparam/mdempsky/1.dir/b.go
Normal file
@ -0,0 +1,9 @@
|
||||
// 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 main
|
||||
|
||||
import "./a"
|
||||
|
||||
func main() { a.F() }
|
7
test/typeparam/mdempsky/1.go
Normal file
7
test/typeparam/mdempsky/1.go
Normal file
@ -0,0 +1,7 @@
|
||||
// compiledir -G=3
|
||||
|
||||
// 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 ignored
|
7
test/typeparam/mdempsky/10.dir/a.go
Normal file
7
test/typeparam/mdempsky/10.dir/a.go
Normal file
@ -0,0 +1,7 @@
|
||||
// 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 a
|
||||
|
||||
type I[T any] interface{ M() T }
|
17
test/typeparam/mdempsky/10.dir/b.go
Normal file
17
test/typeparam/mdempsky/10.dir/b.go
Normal file
@ -0,0 +1,17 @@
|
||||
// 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 main
|
||||
|
||||
import "./a"
|
||||
|
||||
var m = a.I[int].M
|
||||
|
||||
var never bool
|
||||
|
||||
func main() {
|
||||
if never {
|
||||
m(nil)
|
||||
}
|
||||
}
|
7
test/typeparam/mdempsky/10.go
Normal file
7
test/typeparam/mdempsky/10.go
Normal file
@ -0,0 +1,7 @@
|
||||
// rundir -G=3
|
||||
|
||||
// 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 ignored
|
16
test/typeparam/mdempsky/11.go
Normal file
16
test/typeparam/mdempsky/11.go
Normal file
@ -0,0 +1,16 @@
|
||||
// errorcheck
|
||||
|
||||
// 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.
|
||||
|
||||
// Reported by Cuong Manh Le.
|
||||
|
||||
package p
|
||||
|
||||
type a struct{}
|
||||
|
||||
//go:notinheap
|
||||
type b a
|
||||
|
||||
var _ = (*b)(new(a)) // ERROR "cannot convert"
|
11
test/typeparam/mdempsky/12.dir/a.go
Normal file
11
test/typeparam/mdempsky/12.dir/a.go
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 a
|
||||
|
||||
type S[T any] struct {
|
||||
F T
|
||||
}
|
||||
|
||||
var X = S[int]{}
|
13
test/typeparam/mdempsky/12.dir/main.go
Normal file
13
test/typeparam/mdempsky/12.dir/main.go
Normal file
@ -0,0 +1,13 @@
|
||||
// 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 main
|
||||
|
||||
import (
|
||||
"./a"
|
||||
)
|
||||
|
||||
func main() {
|
||||
_ = a.X
|
||||
}
|
9
test/typeparam/mdempsky/12.go
Normal file
9
test/typeparam/mdempsky/12.go
Normal file
@ -0,0 +1,9 @@
|
||||
// rundir -G=3
|
||||
|
||||
// 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.
|
||||
|
||||
// Reported by Cuong Manh Le.
|
||||
|
||||
package ignored
|
38
test/typeparam/mdempsky/13.go
Normal file
38
test/typeparam/mdempsky/13.go
Normal file
@ -0,0 +1,38 @@
|
||||
// run -gcflags=-G=3
|
||||
|
||||
// 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 main
|
||||
|
||||
type Mer interface{ M() }
|
||||
|
||||
func F[T Mer](expectPanic bool) {
|
||||
defer func() {
|
||||
err := recover()
|
||||
if (err != nil) != expectPanic {
|
||||
print("FAIL: (", err, " != nil) != ", expectPanic, "\n")
|
||||
}
|
||||
}()
|
||||
|
||||
var t T
|
||||
T.M(t)
|
||||
}
|
||||
|
||||
type MyMer int
|
||||
|
||||
func (MyMer) M() {}
|
||||
|
||||
func main() {
|
||||
F[Mer](true)
|
||||
F[struct{ Mer }](true)
|
||||
F[*struct{ Mer }](true)
|
||||
|
||||
F[MyMer](false)
|
||||
F[*MyMer](true)
|
||||
F[struct{ MyMer }](false)
|
||||
F[struct{ *MyMer }](true)
|
||||
F[*struct{ MyMer }](true)
|
||||
F[*struct{ *MyMer }](true)
|
||||
}
|
37
test/typeparam/mdempsky/14.go
Normal file
37
test/typeparam/mdempsky/14.go
Normal file
@ -0,0 +1,37 @@
|
||||
// run -gcflags=-G=3
|
||||
|
||||
// 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 main
|
||||
|
||||
func Zero[T any]() (_ T) { return }
|
||||
|
||||
type T[X any] int
|
||||
|
||||
func (T[X]) M() {
|
||||
var have interface{} = Zero[X]()
|
||||
var want interface{} = Zero[MyInt]()
|
||||
|
||||
if have != want {
|
||||
println("FAIL")
|
||||
}
|
||||
}
|
||||
|
||||
type I interface{ M() }
|
||||
|
||||
type MyInt int
|
||||
type U = T[MyInt]
|
||||
|
||||
var x = U(0)
|
||||
var i I = x
|
||||
|
||||
func main() {
|
||||
x.M()
|
||||
U.M(x)
|
||||
(*U).M(&x)
|
||||
|
||||
i.M()
|
||||
I.M(x)
|
||||
}
|
20
test/typeparam/mdempsky/2.go
Normal file
20
test/typeparam/mdempsky/2.go
Normal file
@ -0,0 +1,20 @@
|
||||
// compile -G=3
|
||||
|
||||
// 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 main
|
||||
|
||||
type T[A, B, C any] int
|
||||
|
||||
func (T[A, B, C]) m(x int) {
|
||||
if x <= 0 {
|
||||
return
|
||||
}
|
||||
T[B, C, A](0).m(x - 1)
|
||||
}
|
||||
|
||||
func main() {
|
||||
T[int8, int16, int32](0).m(3)
|
||||
}
|
7
test/typeparam/mdempsky/3.dir/a.go
Normal file
7
test/typeparam/mdempsky/3.dir/a.go
Normal file
@ -0,0 +1,7 @@
|
||||
// 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 a
|
||||
|
||||
func F[T interface{ chan int }](c T) {}
|
9
test/typeparam/mdempsky/3.dir/b.go
Normal file
9
test/typeparam/mdempsky/3.dir/b.go
Normal file
@ -0,0 +1,9 @@
|
||||
// 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 b
|
||||
|
||||
import "./a"
|
||||
|
||||
func g() { a.F(make(chan int)) }
|
7
test/typeparam/mdempsky/3.go
Normal file
7
test/typeparam/mdempsky/3.go
Normal file
@ -0,0 +1,7 @@
|
||||
// compiledir -G=3
|
||||
|
||||
// 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 ignored
|
12
test/typeparam/mdempsky/4.dir/a.go
Normal file
12
test/typeparam/mdempsky/4.dir/a.go
Normal file
@ -0,0 +1,12 @@
|
||||
// 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 a
|
||||
|
||||
func F[T any](T) {
|
||||
Loop:
|
||||
for {
|
||||
break Loop
|
||||
}
|
||||
}
|
9
test/typeparam/mdempsky/4.dir/b.go
Normal file
9
test/typeparam/mdempsky/4.dir/b.go
Normal file
@ -0,0 +1,9 @@
|
||||
// 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 b
|
||||
|
||||
import "./a"
|
||||
|
||||
func f() { a.F(0) }
|
7
test/typeparam/mdempsky/4.go
Normal file
7
test/typeparam/mdempsky/4.go
Normal file
@ -0,0 +1,7 @@
|
||||
// compiledir -G=3
|
||||
|
||||
// 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 ignored
|
15
test/typeparam/mdempsky/5.go
Normal file
15
test/typeparam/mdempsky/5.go
Normal file
@ -0,0 +1,15 @@
|
||||
// compile -G=3
|
||||
|
||||
// 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 a
|
||||
|
||||
type X[T any] int
|
||||
|
||||
func (X[T]) F(T) {}
|
||||
|
||||
func x() {
|
||||
X[interface{}](0).F(0)
|
||||
}
|
11
test/typeparam/mdempsky/6.go
Normal file
11
test/typeparam/mdempsky/6.go
Normal file
@ -0,0 +1,11 @@
|
||||
// compile -G=3
|
||||
|
||||
// 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 a
|
||||
|
||||
type I[T any] interface{ M() T }
|
||||
|
||||
var _ = I[int].M
|
9
test/typeparam/mdempsky/7.dir/a.go
Normal file
9
test/typeparam/mdempsky/7.dir/a.go
Normal file
@ -0,0 +1,9 @@
|
||||
// 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 a
|
||||
|
||||
type I[T any] interface{ M() T }
|
||||
|
||||
var X I[int]
|
9
test/typeparam/mdempsky/7.dir/b.go
Normal file
9
test/typeparam/mdempsky/7.dir/b.go
Normal file
@ -0,0 +1,9 @@
|
||||
// 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 b
|
||||
|
||||
import "./a"
|
||||
|
||||
var _ = a.X
|
7
test/typeparam/mdempsky/7.go
Normal file
7
test/typeparam/mdempsky/7.go
Normal file
@ -0,0 +1,7 @@
|
||||
// compiledir -G=3
|
||||
|
||||
// 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 ignored
|
7
test/typeparam/mdempsky/8.dir/a.go
Normal file
7
test/typeparam/mdempsky/8.dir/a.go
Normal file
@ -0,0 +1,7 @@
|
||||
// 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 a
|
||||
|
||||
func F[T interface{ comparable }]() {}
|
11
test/typeparam/mdempsky/8.dir/b.go
Normal file
11
test/typeparam/mdempsky/8.dir/b.go
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 b
|
||||
|
||||
import "./a"
|
||||
|
||||
func init() {
|
||||
a.F[func()]() // ERROR "does not satisfy comparable"
|
||||
}
|
7
test/typeparam/mdempsky/8.go
Normal file
7
test/typeparam/mdempsky/8.go
Normal file
@ -0,0 +1,7 @@
|
||||
// errorcheckdir -G=3
|
||||
|
||||
// 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 ignored
|
11
test/typeparam/mdempsky/9.go
Normal file
11
test/typeparam/mdempsky/9.go
Normal file
@ -0,0 +1,11 @@
|
||||
// compile -G=3
|
||||
|
||||
// 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 a
|
||||
|
||||
func f[V any]() []V { return []V{0: *new(V)} }
|
||||
|
||||
func g() { f[int]() }
|
Loading…
Reference in New Issue
Block a user