aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/testdata/fixedbugs
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2021-07-12 22:39:39 -0700
committerRobert Griesemer <gri@golang.org>2021-07-14 23:33:52 +0000
commit4ff0e04c2e409aaeebe0cf5287dbed735f84e974 (patch)
treee2d67f5e15c375721fadeaef5fd34e6e9c0ba9b8 /src/cmd/compile/internal/types2/testdata/fixedbugs
parent3a047326e896302724378e5d6b8684851ccfdbfd (diff)
downloadgo-4ff0e04c2e409aaeebe0cf5287dbed735f84e974.tar.gz
go-4ff0e04c2e409aaeebe0cf5287dbed735f84e974.zip
[dev.typeparams] cmd/compile/internal/types2: embedding stand-alone type parameters is not permitted
For #47127. Change-Id: Ie979ff56ae7c2dd0e5ce0ff39588f98ae68b5ee9 Reviewed-on: https://go-review.googlesource.com/c/go/+/334151 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>
Diffstat (limited to 'src/cmd/compile/internal/types2/testdata/fixedbugs')
-rw-r--r--src/cmd/compile/internal/types2/testdata/fixedbugs/issue39634.go27
-rw-r--r--src/cmd/compile/internal/types2/testdata/fixedbugs/issue39680.go24
-rw-r--r--src/cmd/compile/internal/types2/testdata/fixedbugs/issue39948.go210
-rw-r--r--src/cmd/compile/internal/types2/testdata/fixedbugs/issue47127.go237
4 files changed, 47 insertions, 11 deletions
diff --git a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39634.go2 b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39634.go2
index 6d002f5d2f..5cb15e7e58 100644
--- a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39634.go2
+++ b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39634.go2
@@ -31,9 +31,10 @@ type x7[A any] struct{ foo7 }
func main7() { var _ foo7 = x7[int]{} }
// crash 8
-type foo8[A any] interface { ~A }
-func bar8[A foo8[A]](a A) {}
-func main8() {}
+// Embedding stand-alone type parameters is not permitted for now. Disabled.
+// type foo8[A any] interface { ~A }
+// func bar8[A foo8[A]](a A) {}
+// func main8() {}
// crash 9
type foo9[A any] interface { foo9 /* ERROR illegal cycle */ [A] }
diff --git a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39680.go2 b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39680.go2
index 01eadd2dbf..e56bc35475 100644
--- a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39680.go2
+++ b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39680.go2
@@ -4,6 +4,9 @@
package p
+// Embedding stand-alone type parameters is not permitted for now. Disabled.
+
+/*
import "fmt"
// Minimal test case.
@@ -25,3 +28,4 @@ func Print[T constr[T]](s []T) {
func f() {
Print([]string{"Hello, ", "playground\n"})
}
+*/
diff --git a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39948.go2 b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39948.go2
index 6372397ed9..e38e57268d 100644
--- a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39948.go2
+++ b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39948.go2
@@ -2,14 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// TODO(gri) Eventually, once we disallow type lists, we need to
-// adjust this code: for 1.17 we don't accept type parameters,
-// and for 1.18 this code is valid.
-// Leaving for now so we can see that existing errors
-// are being reported.
-
-package go1_17 // don't permit non-interface elements in interfaces
+package p
type T[P any] interface{
- P // ERROR P is a type parameter, not an interface
+ P // ERROR cannot embed a type parameter
}
diff --git a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue47127.go2 b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue47127.go2
new file mode 100644
index 0000000000..387c946957
--- /dev/null
+++ b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue47127.go2
@@ -0,0 +1,37 @@
+// 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.
+
+// Embedding of stand-alone type parameters is not permitted.
+
+package p
+
+type (
+ _[P any] interface{ *P | []P | chan P | map[string]P }
+ _[P any] interface{ P /* ERROR "cannot embed a type parameter" */ }
+ _[P any] interface{ ~P /* ERROR "cannot embed a type parameter" */ }
+ _[P any] interface{ int | P /* ERROR "cannot embed a type parameter" */ }
+ _[P any] interface{ int | ~P /* ERROR "cannot embed a type parameter" */ }
+)
+
+func _[P any]() {
+ type (
+ _[P any] interface{ *P | []P | chan P | map[string]P }
+ _[P any] interface{ P /* ERROR "cannot embed a type parameter" */ }
+ _[P any] interface{ ~P /* ERROR "cannot embed a type parameter" */ }
+ _[P any] interface{ int | P /* ERROR "cannot embed a type parameter" */ }
+ _[P any] interface{ int | ~P /* ERROR "cannot embed a type parameter" */ }
+
+ _ interface{ *P | []P | chan P | map[string]P }
+ _ interface{ P /* ERROR "cannot embed a type parameter" */ }
+ _ interface{ ~P /* ERROR "cannot embed a type parameter" */ }
+ _ interface{ int | P /* ERROR "cannot embed a type parameter" */ }
+ _ interface{ int | ~P /* ERROR "cannot embed a type parameter" */ }
+ )
+}
+
+func _[P any, Q interface{ *P | []P | chan P | map[string]P }]()
+func _[P any, Q interface{ P /* ERROR "cannot embed a type parameter" */ }]()
+func _[P any, Q interface{ ~P /* ERROR "cannot embed a type parameter" */ }]()
+func _[P any, Q interface{ int | P /* ERROR "cannot embed a type parameter" */ }]()
+func _[P any, Q interface{ int | ~P /* ERROR "cannot embed a type parameter" */ }]()