aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/testdata/examples/inference.go2
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2021-08-09 10:53:43 -0700
committerRobert Griesemer <gri@golang.org>2021-08-10 01:20:34 +0000
commite4cfa2f6dad8c73e98a4149948ded424df9c8501 (patch)
tree1247e3badd9ef3e109a0daf7eaf1cefb18c6c434 /src/cmd/compile/internal/types2/testdata/examples/inference.go2
parent508624f359f168cab32814f63d29a4305fb01588 (diff)
downloadgo-e4cfa2f6dad8c73e98a4149948ded424df9c8501.tar.gz
go-e4cfa2f6dad8c73e98a4149948ded424df9c8501.zip
[dev.typeparams] cmd/compile/internal/types2: parameterized functions must have a body
Add the respective check and add missing bodies to tests. Use {} as body for functions that don't return a result. Use { panic(0) } as body for functions that return a result. For #47069. Change-Id: Ia5d7525c9c036baf8a955d13bff448401e08235e Reviewed-on: https://go-review.googlesource.com/c/go/+/340911 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types2/testdata/examples/inference.go2')
-rw-r--r--src/cmd/compile/internal/types2/testdata/examples/inference.go28
1 files changed, 4 insertions, 4 deletions
diff --git a/src/cmd/compile/internal/types2/testdata/examples/inference.go2 b/src/cmd/compile/internal/types2/testdata/examples/inference.go2
index 75d47d2c9b..e169aec746 100644
--- a/src/cmd/compile/internal/types2/testdata/examples/inference.go2
+++ b/src/cmd/compile/internal/types2/testdata/examples/inference.go2
@@ -10,7 +10,7 @@ type Ordered interface {
~int|~float64|~string
}
-func min[T Ordered](x, y T) T
+func min[T Ordered](x, y T) T { panic(0) }
func _() {
// min can be called with explicit instantiation.
@@ -37,7 +37,7 @@ func _() {
_ = min("foo", "bar")
}
-func mixed[T1, T2, T3 any](T1, T2, T3)
+func mixed[T1, T2, T3 any](T1, T2, T3) {}
func _() {
// mixed can be called with explicit instantiation.
@@ -54,7 +54,7 @@ func _() {
mixed[int, string](1.1 /* ERROR cannot use 1.1 */ , "", false)
}
-func related1[Slice interface{~[]Elem}, Elem any](s Slice, e Elem)
+func related1[Slice interface{~[]Elem}, Elem any](s Slice, e Elem) {}
func _() {
// related1 can be called with explicit instantiation.
@@ -78,7 +78,7 @@ func _() {
related1(si, "foo" /* ERROR cannot use "foo" */ )
}
-func related2[Elem any, Slice interface{~[]Elem}](e Elem, s Slice)
+func related2[Elem any, Slice interface{~[]Elem}](e Elem, s Slice) {}
func _() {
// related2 can be called with explicit instantiation.