aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/testdata/check
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2021-08-24 18:07:42 -0700
committerRobert Griesemer <gri@golang.org>2021-08-25 23:43:53 +0000
commit4068fb6c2162b38db7912903ff12bafe9f5ca9bb (patch)
tree9bd25a1f5bd6d796bb080499c5cb27a49276f616 /src/cmd/compile/internal/types2/testdata/check
parentbf0bc4122fd4b3a75c2f9c107895cd5e2f89b90e (diff)
downloadgo-4068fb6c2162b38db7912903ff12bafe9f5ca9bb.tar.gz
go-4068fb6c2162b38db7912903ff12bafe9f5ca9bb.zip
cmd/compile: always accept 1.18 syntax but complain if not 1.18
This CL configures the parser to always accept 1.18 syntax (type parameters, type instantiations, interface elements), even when -lang is set to an earlier release. Instead, the type checker looks for 1.18 operations and complains if the language version is set to an earlier release. Doing these checks during type checking is necessary because it it is possible to write "generic" code using pre-1.18 syntax; for instance, an imported generic function may be implicitly instantiated (as in imported.Max(2, 3)), or an imported constraint interface may be embedded in an "ordinary" interface. Fixes #47818. Change-Id: I83ec302b3f4ba7196c0a4743c03670cfb901310d Reviewed-on: https://go-review.googlesource.com/c/go/+/344871 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types2/testdata/check')
-rw-r--r--src/cmd/compile/internal/types2/testdata/check/decls0.src2
-rw-r--r--src/cmd/compile/internal/types2/testdata/check/issues.src6
-rw-r--r--src/cmd/compile/internal/types2/testdata/check/main.go22
-rw-r--r--src/cmd/compile/internal/types2/testdata/check/typeparams.go24
4 files changed, 7 insertions, 7 deletions
diff --git a/src/cmd/compile/internal/types2/testdata/check/decls0.src b/src/cmd/compile/internal/types2/testdata/check/decls0.src
index f051a4f2ac..09e5d5c5ad 100644
--- a/src/cmd/compile/internal/types2/testdata/check/decls0.src
+++ b/src/cmd/compile/internal/types2/testdata/check/decls0.src
@@ -146,7 +146,7 @@ type (
m1(I5)
}
I6 interface {
- S0 /* ERROR "not an interface" */
+ S0 /* ERROR "non-interface type S0" */
}
I7 interface {
I1
diff --git a/src/cmd/compile/internal/types2/testdata/check/issues.src b/src/cmd/compile/internal/types2/testdata/check/issues.src
index 692ed37ef4..d83a95af0e 100644
--- a/src/cmd/compile/internal/types2/testdata/check/issues.src
+++ b/src/cmd/compile/internal/types2/testdata/check/issues.src
@@ -79,11 +79,11 @@ func issue9473(a []int, b ...int) {
// Check that embedding a non-interface type in an interface results in a good error message.
func issue10979() {
type _ interface {
- int /* ERROR int is not an interface */
+ int /* ERROR non-interface type int */
}
type T struct{}
type _ interface {
- T /* ERROR T is not an interface */
+ T /* ERROR non-interface type T */
}
type _ interface {
nosuchtype /* ERROR undeclared name: nosuchtype */
@@ -280,7 +280,7 @@ type issue25301b /* ERROR cycle */ = interface {
}
type issue25301c interface {
- notE // ERROR struct\{\} is not an interface
+ notE // ERROR non-interface type struct\{\}
}
type notE = struct{}
diff --git a/src/cmd/compile/internal/types2/testdata/check/main.go2 b/src/cmd/compile/internal/types2/testdata/check/main.go2
index b7ddeaa1a8..395e3bfec8 100644
--- a/src/cmd/compile/internal/types2/testdata/check/main.go2
+++ b/src/cmd/compile/internal/types2/testdata/check/main.go2
@@ -4,4 +4,4 @@
package main
-func /* ERROR "func main must have no type parameters" */ main[T any]() {}
+func main [T /* ERROR "func main must have no type parameters" */ any]() {}
diff --git a/src/cmd/compile/internal/types2/testdata/check/typeparams.go2 b/src/cmd/compile/internal/types2/testdata/check/typeparams.go2
index 1ad80b1e1b..765d561f3b 100644
--- a/src/cmd/compile/internal/types2/testdata/check/typeparams.go2
+++ b/src/cmd/compile/internal/types2/testdata/check/typeparams.go2
@@ -304,8 +304,8 @@ var _ = f8[int, float64](0, 0, nil...) // test case for #18268
// init functions cannot have type parameters
func init() {}
-func init[/* ERROR func init must have no type parameters */ _ any]() {}
-func init[/* ERROR func init must have no type parameters */ P any]() {}
+func init[_ /* ERROR func init must have no type parameters */ any]() {}
+func init[P /* ERROR func init must have no type parameters */ any]() {}
type T struct {}