Robert Griesemer submitted this change.
cmd/compile: use "satisfies" (not "implements") for constraint errors
Per the latest spec, we distinguish between interface implementation
and constraint satisfaction. Use the verb "satisfy" when reporting
an error about failing constraint satisfaction.
This CL only changes error messages. It has no impact on correct code.
Fixes #57564.
Change-Id: I6dfb3b2093c2e04fe5566628315fb5f6bd709f17
Reviewed-on: https://go-review.googlesource.com/c/go/+/460396
Reviewed-by: Robert Griesemer <g...@google.com>
TryBot-Result: Gopher Robot <go...@golang.org>
Run-TryBot: Robert Griesemer <g...@google.com>
Reviewed-by: Ian Lance Taylor <ia...@google.com>
---
M src/cmd/compile/internal/types2/instantiate.go
M src/go/types/instantiate.go
M src/internal/types/testdata/check/issues1.go
M src/internal/types/testdata/check/typeinst1.go
M src/internal/types/testdata/examples/inference.go
M src/internal/types/testdata/fixedbugs/issue39754.go
M src/internal/types/testdata/fixedbugs/issue40350.go
M src/internal/types/testdata/fixedbugs/issue45920.go
M src/internal/types/testdata/fixedbugs/issue47411.go
M src/internal/types/testdata/fixedbugs/issue49112.go
M src/internal/types/testdata/fixedbugs/issue49179.go
M src/internal/types/testdata/fixedbugs/issue49739.go
M src/internal/types/testdata/fixedbugs/issue50417.go
M src/internal/types/testdata/fixedbugs/issue50646.go
M src/internal/types/testdata/fixedbugs/issue50782.go
M src/internal/types/testdata/fixedbugs/issue51257.go
M src/internal/types/testdata/fixedbugs/issue51376.go
M src/internal/types/testdata/fixedbugs/issue51472.go
M src/internal/types/testdata/fixedbugs/issue57486.go
M src/internal/types/testdata/spec/comparable.go
M src/internal/types/testdata/spec/comparable1.19.go
M src/internal/types/testdata/spec/oldcomparable.go
M test/typeparam/mdempsky/8.dir/b.go
M test/typeparam/mincheck.dir/main.go
24 files changed, 133 insertions(+), 101 deletions(-)
diff --git a/src/cmd/compile/internal/types2/instantiate.go b/src/cmd/compile/internal/types2/instantiate.go
index 52f60d7..f028161 100644
--- a/src/cmd/compile/internal/types2/instantiate.go
+++ b/src/cmd/compile/internal/types2/instantiate.go
@@ -188,7 +188,7 @@
// is set, T is a type constraint.
//
// If the provided cause is non-nil, it may be set to an error string
-// explaining why V does not implement T.
+// explaining why V does not implement (or satisfy, for constraints) T.
func (check *Checker) implements(V, T Type, constraint bool, cause *string) bool {
Vu := under(V)
Tu := under(T)
@@ -199,6 +199,11 @@
return true // avoid follow-on errors (see issue #49541 for an example)
}
+ verb := "implement"
+ if constraint {
+ verb = "satisfy"
+ }
+
Ti, _ := Tu.(*Interface)
if Ti == nil {
if cause != nil {
@@ -208,7 +213,7 @@
} else {
detail = check.sprintf("%s is not an interface", T)
}
- *cause = check.sprintf("%s does not implement %s (%s)", V, T, detail)
+ *cause = check.sprintf("%s does not %s %s (%s)", V, verb, T, detail)
}
return false
}
@@ -230,7 +235,7 @@
// No type with non-empty type set satisfies the empty type set.
if Ti.typeSet().IsEmpty() {
if cause != nil {
- *cause = check.sprintf("cannot implement %s (empty type set)", T)
+ *cause = check.sprintf("cannot %s %s (empty type set)", verb, T)
}
return false
}
@@ -238,7 +243,7 @@
// V must implement T's methods, if any.
if m, wrong := check.missingMethod(V, Ti, true); m != nil /* !Implements(V, Ti) */ {
if cause != nil {
- *cause = check.sprintf("%s does not implement %s %s", V, T, check.missingMethodCause(V, T, m, wrong))
+ *cause = check.sprintf("%s does not %s %s %s", V, verb, T, check.missingMethodCause(V, T, m, wrong))
}
return false
}
@@ -258,7 +263,7 @@
// TODO(gri) remove this check for Go 1.21
if check != nil && check.conf.OldComparableSemantics {
if cause != nil {
- *cause = check.sprintf("%s does not implement comparable", V)
+ *cause = check.sprintf("%s does not %s comparable", V, verb)
}
return false
}
@@ -270,12 +275,12 @@
return true
}
if cause != nil {
- *cause = check.sprintf("%s to implement comparable requires go1.20 or later", V)
+ *cause = check.sprintf("%s to %s comparable requires go1.20 or later", V, verb)
}
return false
}
if cause != nil {
- *cause = check.sprintf("%s does not implement comparable", V)
+ *cause = check.sprintf("%s does not %s comparable", V, verb)
}
return false
}
@@ -293,7 +298,7 @@
if !Vi.typeSet().subsetOf(Ti.typeSet()) {
// TODO(gri) report which type is missing
if cause != nil {
- *cause = check.sprintf("%s does not implement %s", V, T)
+ *cause = check.sprintf("%s does not %s %s", V, verb, T)
}
return false
}
@@ -320,9 +325,9 @@
}) {
if cause != nil {
if alt != nil {
- *cause = check.sprintf("%s does not implement %s (possibly missing ~ for %s in constraint %s)", V, T, alt, T)
+ *cause = check.sprintf("%s does not %s %s (possibly missing ~ for %s in constraint %s)", V, verb, T, alt, T)
} else {
- *cause = check.sprintf("%s does not implement %s (%s missing in %s)", V, T, V, Ti.typeSet().terms)
+ *cause = check.sprintf("%s does not %s %s (%s missing in %s)", V, verb, T, V, Ti.typeSet().terms)
}
}
return false
diff --git a/src/go/types/instantiate.go b/src/go/types/instantiate.go
index 59ac100..9f565c3 100644
--- a/src/go/types/instantiate.go
+++ b/src/go/types/instantiate.go
@@ -188,7 +188,7 @@
// is set, T is a type constraint.
//
// If the provided cause is non-nil, it may be set to an error string
-// explaining why V does not implement T.
+// explaining why V does not implement (or satisfy, for constraints) T.
func (check *Checker) implements(V, T Type, constraint bool, cause *string) bool {
Vu := under(V)
Tu := under(T)
@@ -199,6 +199,11 @@
return true // avoid follow-on errors (see issue #49541 for an example)
}
+ verb := "implement"
+ if constraint {
+ verb = "satisfy"
+ }
+
Ti, _ := Tu.(*Interface)
if Ti == nil {
if cause != nil {
@@ -208,7 +213,7 @@
} else {
detail = check.sprintf("%s is not an interface", T)
}
- *cause = check.sprintf("%s does not implement %s (%s)", V, T, detail)
+ *cause = check.sprintf("%s does not %s %s (%s)", V, verb, T, detail)
}
return false
}
@@ -230,7 +235,7 @@
// No type with non-empty type set satisfies the empty type set.
if Ti.typeSet().IsEmpty() {
if cause != nil {
- *cause = check.sprintf("cannot implement %s (empty type set)", T)
+ *cause = check.sprintf("cannot %s %s (empty type set)", verb, T)
}
return false
}
@@ -238,7 +243,7 @@
// V must implement T's methods, if any.
if m, wrong := check.missingMethod(V, Ti, true); m != nil /* !Implements(V, Ti) */ {
if cause != nil {
- *cause = check.sprintf("%s does not implement %s %s", V, T, check.missingMethodCause(V, T, m, wrong))
+ *cause = check.sprintf("%s does not %s %s %s", V, verb, T, check.missingMethodCause(V, T, m, wrong))
}
return false
}
@@ -258,7 +263,7 @@
// TODO(gri) remove this check for Go 1.21
if check != nil && check.conf.oldComparableSemantics {
if cause != nil {
- *cause = check.sprintf("%s does not implement comparable", V)
+ *cause = check.sprintf("%s does not %s comparable", V, verb)
}
return false
}
@@ -270,12 +275,12 @@
return true
}
if cause != nil {
- *cause = check.sprintf("%s to implement comparable requires go1.20 or later", V)
+ *cause = check.sprintf("%s to %s comparable requires go1.20 or later", V, verb)
}
return false
}
if cause != nil {
- *cause = check.sprintf("%s does not implement comparable", V)
+ *cause = check.sprintf("%s does not %s comparable", V, verb)
}
return false
}
@@ -293,7 +298,7 @@
if !Vi.typeSet().subsetOf(Ti.typeSet()) {
// TODO(gri) report which type is missing
if cause != nil {
- *cause = check.sprintf("%s does not implement %s", V, T)
+ *cause = check.sprintf("%s does not %s %s", V, verb, T)
}
return false
}
@@ -320,9 +325,9 @@
}) {
if cause != nil {
if alt != nil {
- *cause = check.sprintf("%s does not implement %s (possibly missing ~ for %s in constraint %s)", V, T, alt, T)
+ *cause = check.sprintf("%s does not %s %s (possibly missing ~ for %s in constraint %s)", V, verb, T, alt, T)
} else {
- *cause = check.sprintf("%s does not implement %s (%s missing in %s)", V, T, V, Ti.typeSet().terms)
+ *cause = check.sprintf("%s does not %s %s (%s missing in %s)", V, verb, T, V, Ti.typeSet().terms)
}
}
return false
diff --git a/src/internal/types/testdata/check/issues1.go b/src/internal/types/testdata/check/issues1.go
index 02ad822..2f3414d 100644
--- a/src/internal/types/testdata/check/issues1.go
+++ b/src/internal/types/testdata/check/issues1.go
@@ -22,7 +22,7 @@
eql(x, x)
eql(y, y)
eql(y, nil /* ERROR cannot use nil as Y value in argument to eql */ )
- eql[io /* ERROR does not implement comparable */ .Reader](nil, nil)
+ eql[io /* ERROR does not satisfy comparable */ .Reader](nil, nil)
}
// If we have a receiver of pointer to type parameter type (below: *T)
@@ -58,7 +58,7 @@
type T1[P interface{~uint}] struct{}
func _[P any]() {
- _ = T1[P /* ERROR P does not implement interface{~uint} */ ]{}
+ _ = T1[P /* ERROR P does not satisfy interface{~uint} */ ]{}
}
// This is the original (simplified) program causing the same issue.
@@ -74,8 +74,8 @@
return u.s + 1
}
-func NewT2[U any]() T2[U /* ERROR U does not implement Unsigned */ ] {
- return T2[U /* ERROR U does not implement Unsigned */ ]{}
+func NewT2[U any]() T2[U /* ERROR U does not satisfy Unsigned */ ] {
+ return T2[U /* ERROR U does not satisfy Unsigned */ ]{}
}
func _() {
diff --git a/src/internal/types/testdata/check/typeinst1.go b/src/internal/types/testdata/check/typeinst1.go
index e7b4539..e7bb247 100644
--- a/src/internal/types/testdata/check/typeinst1.go
+++ b/src/internal/types/testdata/check/typeinst1.go
@@ -210,7 +210,7 @@
var _ = f0[int]
var _ = f0[bool]
var _ = f0[string]
-var _ = f0[float64 /* ERROR does not implement I0 */ ]
+var _ = f0[float64 /* ERROR does not satisfy I0 */ ]
type I01 interface {
E0
@@ -219,9 +219,9 @@
func f01[T I01]() {}
var _ = f01[int]
-var _ = f01[bool /* ERROR does not implement I0 */ ]
+var _ = f01[bool /* ERROR does not satisfy I0 */ ]
var _ = f01[string]
-var _ = f01[float64 /* ERROR does not implement I0 */ ]
+var _ = f01[float64 /* ERROR does not satisfy I0 */ ]
type I012 interface {
E0
@@ -230,10 +230,10 @@
}
func f012[T I012]() {}
-var _ = f012[int /* ERROR cannot implement I012.*empty type set */ ]
-var _ = f012[bool /* ERROR cannot implement I012.*empty type set */ ]
-var _ = f012[string /* ERROR cannot implement I012.*empty type set */ ]
-var _ = f012[float64 /* ERROR cannot implement I012.*empty type set */ ]
+var _ = f012[int /* ERROR cannot satisfy I012.*empty type set */ ]
+var _ = f012[bool /* ERROR cannot satisfy I012.*empty type set */ ]
+var _ = f012[string /* ERROR cannot satisfy I012.*empty type set */ ]
+var _ = f012[float64 /* ERROR cannot satisfy I012.*empty type set */ ]
type I12 interface {
E1
@@ -241,9 +241,9 @@
}
func f12[T I12]() {}
-var _ = f12[int /* ERROR does not implement I12 */ ]
-var _ = f12[bool /* ERROR does not implement I12 */ ]
-var _ = f12[string /* ERROR does not implement I12 */ ]
+var _ = f12[int /* ERROR does not satisfy I12 */ ]
+var _ = f12[bool /* ERROR does not satisfy I12 */ ]
+var _ = f12[string /* ERROR does not satisfy I12 */ ]
var _ = f12[float64]
type I0_ interface {
@@ -253,9 +253,9 @@
func f0_[T I0_]() {}
var _ = f0_[int]
-var _ = f0_[bool /* ERROR does not implement I0_ */ ]
-var _ = f0_[string /* ERROR does not implement I0_ */ ]
-var _ = f0_[float64 /* ERROR does not implement I0_ */ ]
+var _ = f0_[bool /* ERROR does not satisfy I0_ */ ]
+var _ = f0_[string /* ERROR does not satisfy I0_ */ ]
+var _ = f0_[float64 /* ERROR does not satisfy I0_ */ ]
// Using a function instance as a type is an error.
var _ f0 // ERROR not a type
@@ -273,7 +273,7 @@
func hh[T ~int]() {}
func _[T none]() {
- _ = ff[int /* ERROR cannot implement none \(empty type set\) */ ]
+ _ = ff[int /* ERROR cannot satisfy none \(empty type set\) */ ]
_ = ff[T] // pathological but ok because T's type set is empty, too
_ = gg[int]
_ = gg[T]
diff --git a/src/internal/types/testdata/examples/inference.go b/src/internal/types/testdata/examples/inference.go
index 23a3d81..073df9c 100644
--- a/src/internal/types/testdata/examples/inference.go
+++ b/src/internal/types/testdata/examples/inference.go
@@ -97,7 +97,7 @@
// last.
related2(1.2, []float64{})
related2(1.0, []int{})
- related2 /* ERROR does not implement */ (float64(1.0), []int{}) // TODO(gri) fix error position
+ related2 /* ERROR does not satisfy */ (float64(1.0), []int{}) // TODO(gri) fix error position
}
type List[P any] []P
diff --git a/src/internal/types/testdata/fixedbugs/issue39754.go b/src/internal/types/testdata/fixedbugs/issue39754.go
index 9edd239..97365e2 100644
--- a/src/internal/types/testdata/fixedbugs/issue39754.go
+++ b/src/internal/types/testdata/fixedbugs/issue39754.go
@@ -16,6 +16,6 @@
func _() {
f[int, Optional[int], Optional[int]]()
- _ = f[int, Optional[int], Optional /* ERROR does not implement Box */ [string]]
- _ = f[int, Optional[int], Optional /* ERROR Optional.* does not implement Box.* */ [string]]
+ _ = f[int, Optional[int], Optional /* ERROR does not satisfy Box */ [string]]
+ _ = f[int, Optional[int], Optional /* ERROR Optional.* does not satisfy Box.* */ [string]]
}
diff --git a/src/internal/types/testdata/fixedbugs/issue40350.go b/src/internal/types/testdata/fixedbugs/issue40350.go
index 7ffd551..96ad167 100644
--- a/src/internal/types/testdata/fixedbugs/issue40350.go
+++ b/src/internal/types/testdata/fixedbugs/issue40350.go
@@ -12,5 +12,5 @@
func f[T number]() {}
func _() {
- _ = f[int /* ERROR int does not implement number \(int missing in float64 | ~int32\)*/]
+ _ = f[int /* ERROR int does not satisfy number \(int missing in float64 \| ~int32\)*/]
}
diff --git a/src/internal/types/testdata/fixedbugs/issue45920.go b/src/internal/types/testdata/fixedbugs/issue45920.go
index d67dfc0..0a281c5 100644
--- a/src/internal/types/testdata/fixedbugs/issue45920.go
+++ b/src/internal/types/testdata/fixedbugs/issue45920.go
@@ -8,10 +8,10 @@
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 satisfy 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 satisfy chan int \| chan<- int */ (ch) }
func _(ch chan<- int) { f2(ch) }
diff --git a/src/internal/types/testdata/fixedbugs/issue47411.go b/src/internal/types/testdata/fixedbugs/issue47411.go
index 1230307..33b169a 100644
--- a/src/internal/types/testdata/fixedbugs/issue47411.go
+++ b/src/internal/types/testdata/fixedbugs/issue47411.go
@@ -15,12 +15,12 @@
_ = f[int]
_ = f[P]
_ = f[Q]
- _ = f[func /* ERROR does not implement comparable */ ()]
- _ = f[R /* ERROR R does not implement comparable */ ]
+ _ = f[func /* ERROR does not satisfy comparable */ ()]
+ _ = f[R /* ERROR R does not satisfy comparable */ ]
_ = g[int]
- _ = g[P /* ERROR P does not implement interface{interface{comparable; ~int \| ~string} */ ]
+ _ = g[P /* ERROR P does not satisfy interface{interface{comparable; ~int \| ~string} */ ]
_ = g[Q]
- _ = g[func /* ERROR func\(\) does not implement interface{interface{comparable; ~int \| ~string}} */ ()]
- _ = g[R /* ERROR R does not implement interface{interface{comparable; ~int \| ~string} */ ]
+ _ = g[func /* ERROR func\(\) does not satisfy interface{interface{comparable; ~int \| ~string}} */ ()]
+ _ = g[R /* ERROR R does not satisfy interface{interface{comparable; ~int \| ~string} */ ]
}
diff --git a/src/internal/types/testdata/fixedbugs/issue49112.go b/src/internal/types/testdata/fixedbugs/issue49112.go
index 61b757c..dea2608 100644
--- a/src/internal/types/testdata/fixedbugs/issue49112.go
+++ b/src/internal/types/testdata/fixedbugs/issue49112.go
@@ -8,8 +8,8 @@
func _() {
_ = f[int]
- _ = f[[ /* ERROR \[\]int does not implement int */ ]int]
+ _ = f[[ /* ERROR \[\]int does not satisfy int */ ]int]
f(0)
- f/* ERROR \[\]int does not implement int */ ([]int{})
+ f/* ERROR \[\]int does not satisfy int */ ([]int{})
}
diff --git a/src/internal/types/testdata/fixedbugs/issue49179.go b/src/internal/types/testdata/fixedbugs/issue49179.go
index 8890e92..468d83e 100644
--- a/src/internal/types/testdata/fixedbugs/issue49179.go
+++ b/src/internal/types/testdata/fixedbugs/issue49179.go
@@ -17,7 +17,7 @@
_ = 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 satisfy int \(possibly missing ~ for int in constraint int\) */ (x)
}
// test case from the issue
@@ -33,5 +33,5 @@
type MySlice []int
func f(s MySlice) {
- Map[MySlice /* ERROR MySlice does not implement SliceConstraint\[int\] \(possibly missing ~ for \[\]int in constraint SliceConstraint\[int\]\) */, int](s, nil)
+ Map[MySlice /* ERROR MySlice does not satisfy SliceConstraint\[int\] \(possibly missing ~ for \[\]int in constraint SliceConstraint\[int\]\) */, int](s, nil)
}
diff --git a/src/internal/types/testdata/fixedbugs/issue49739.go b/src/internal/types/testdata/fixedbugs/issue49739.go
index 46b1e71..7feb563 100644
--- a/src/internal/types/testdata/fixedbugs/issue49739.go
+++ b/src/internal/types/testdata/fixedbugs/issue49739.go
@@ -17,7 +17,7 @@
func h[_ C | int]() {}
func _() {
- _ = f[int /* ERROR cannot implement C \(empty type set\) */]
- _ = g[int /* ERROR cannot implement interface{C} \(empty type set\) */]
+ _ = f[int /* ERROR cannot satisfy C \(empty type set\) */]
+ _ = g[int /* ERROR cannot satisfy interface{C} \(empty type set\) */]
_ = h[int]
}
diff --git a/src/internal/types/testdata/fixedbugs/issue50417.go b/src/internal/types/testdata/fixedbugs/issue50417.go
index 2caef1b..69ebf31 100644
--- a/src/internal/types/testdata/fixedbugs/issue50417.go
+++ b/src/internal/types/testdata/fixedbugs/issue50417.go
@@ -25,8 +25,8 @@
var _ = f0[Sf]
var _ = f0t[Sf]
-var _ = f0[Sm /* ERROR does not implement */ ]
-var _ = f0t[Sm /* ERROR does not implement */ ]
+var _ = f0[Sm /* ERROR does not satisfy */ ]
+var _ = f0t[Sm /* ERROR does not satisfy */ ]
func f1[P interface{ Sf; m() }](p P) {
_ = p.f // ERROR p\.f undefined
@@ -35,7 +35,7 @@
}
var _ = f1[Sf /* ERROR missing method m */ ]
-var _ = f1[Sm /* ERROR does not implement */ ]
+var _ = f1[Sm /* ERROR does not satisfy */ ]
type Sm struct {}
diff --git a/src/internal/types/testdata/fixedbugs/issue50646.go b/src/internal/types/testdata/fixedbugs/issue50646.go
index bc53700..ed7261c 100644
--- a/src/internal/types/testdata/fixedbugs/issue50646.go
+++ b/src/internal/types/testdata/fixedbugs/issue50646.go
@@ -13,16 +13,16 @@
func _[P comparable, Q ~int, R any]() {
_ = f1[int]
- _ = f1[T /* ERROR T does not implement comparable */ ]
- _ = f1[any /* ERROR any does not implement comparable */ ]
+ _ = f1[T /* ERROR T does not satisfy comparable */ ]
+ _ = f1[any /* ERROR any does not satisfy comparable */ ]
_ = f1[P]
_ = f1[Q]
- _ = f1[R /* ERROR R does not implement comparable */]
+ _ = f1[R /* ERROR R does not satisfy comparable */]
_ = f2[int]
- _ = f2[T /* ERROR T does not implement comparable */ ]
- _ = f2[any /* ERROR any does not implement comparable */ ]
+ _ = f2[T /* ERROR T does not satisfy comparable */ ]
+ _ = f2[any /* ERROR any does not satisfy comparable */ ]
_ = f2[P]
_ = f2[Q]
- _ = f2[R /* ERROR R does not implement comparable */]
+ _ = f2[R /* ERROR R does not satisfy comparable */]
}
diff --git a/src/internal/types/testdata/fixedbugs/issue50782.go b/src/internal/types/testdata/fixedbugs/issue50782.go
index fd1ab11..0e7b712 100644
--- a/src/internal/types/testdata/fixedbugs/issue50782.go
+++ b/src/internal/types/testdata/fixedbugs/issue50782.go
@@ -21,7 +21,7 @@
// AbsDifference computes the absolute value of the difference of
// a and b, where the absolute value is determined by the Abs method.
-func absDifference[T numericAbs[T /* ERROR T does not implement Numeric */]](a, b T) T {
+func absDifference[T numericAbs[T /* ERROR T does not satisfy Numeric */]](a, b T) T {
// Field accesses are not permitted for now. Keep an error so
// we can find and fix this code once the situation changes.
return a.Value // ERROR a\.Value undefined
@@ -33,15 +33,15 @@
// The second example from the issue.
type T[P int] struct{ f P }
-func _[P T[P /* ERROR "P does not implement int" */ ]]() {}
+func _[P T[P /* ERROR "P does not satisfy int" */ ]]() {}
// Additional tests
-func _[P T[T /* ERROR "T\[P\] does not implement int" */ [P /* ERROR "P does not implement int" */ ]]]() {}
-func _[P T[Q /* ERROR "Q does not implement int" */ ], Q T[P /* ERROR "P does not implement int" */ ]]() {}
+func _[P T[T /* ERROR "T\[P\] does not satisfy int" */ [P /* ERROR "P does not satisfy int" */ ]]]() {}
+func _[P T[Q /* ERROR "Q does not satisfy int" */ ], Q T[P /* ERROR "P does not satisfy int" */ ]]() {}
func _[P T[Q], Q int]() {}
type C[P comparable] struct{ f P }
func _[P C[C[P]]]() {}
-func _[P C[C /* ERROR "C\[Q\] does not implement comparable" */ [Q /* ERROR "Q does not implement comparable" */]], Q func()]() {}
+func _[P C[C /* ERROR "C\[Q\] does not satisfy comparable" */ [Q /* ERROR "Q does not satisfy comparable" */]], Q func()]() {}
func _[P [10]C[P]]() {}
func _[P struct{ f C[C[P]]}]() {}
diff --git a/src/internal/types/testdata/fixedbugs/issue51257.go b/src/internal/types/testdata/fixedbugs/issue51257.go
index 4730c98..be4b81fe 100644
--- a/src/internal/types/testdata/fixedbugs/issue51257.go
+++ b/src/internal/types/testdata/fixedbugs/issue51257.go
@@ -14,13 +14,13 @@
func _[P1 comparable, P2 S2]() {
_ = f[S1]
- _ = f[S2 /* ERROR S2 does not implement comparable */ ]
- _ = f[S3 /* ERROR S3 does not implement comparable */ ]
+ _ = f[S2 /* ERROR S2 does not satisfy comparable */ ]
+ _ = f[S3 /* ERROR S3 does not satisfy comparable */ ]
type L1 struct { x P1 }
type L2 struct { x P2 }
_ = f[L1]
- _ = f[L2 /* ERROR L2 does not implement comparable */ ]
+ _ = f[L2 /* ERROR L2 does not satisfy comparable */ ]
}
@@ -41,7 +41,7 @@
type T struct{ x any }
func main() {
- NewSetFromSlice /* ERROR T does not implement comparable */ ([]T{
+ NewSetFromSlice /* ERROR T does not satisfy comparable */ ([]T{
{"foo"},
{5},
})
diff --git a/src/internal/types/testdata/fixedbugs/issue51376.go b/src/internal/types/testdata/fixedbugs/issue51376.go
index d51607b..3801d68 100644
--- a/src/internal/types/testdata/fixedbugs/issue51376.go
+++ b/src/internal/types/testdata/fixedbugs/issue51376.go
@@ -12,7 +12,7 @@
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 satisfy map\[K\]V */ (m1) // M1 has tilde
var m2 M2
f(m2)
@@ -20,5 +20,5 @@
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 satisfy map\[string\]int */ (m3) // M in g does not have tilde
}
diff --git a/src/internal/types/testdata/fixedbugs/issue51472.go b/src/internal/types/testdata/fixedbugs/issue51472.go
index 52ae09d..a0f9e9c 100644
--- a/src/internal/types/testdata/fixedbugs/issue51472.go
+++ b/src/internal/types/testdata/fixedbugs/issue51472.go
@@ -49,6 +49,6 @@
}
func _(s []byte) {
- f /* ERROR \[\]byte does not implement interface{comparable; \[\]byte \| string} */ (s)
- _ = f[[ /* ERROR does not implement */ ]byte]
+ f /* ERROR \[\]byte does not satisfy interface{comparable; \[\]byte \| string} */ (s)
+ _ = f[[ /* ERROR does not satisfy */ ]byte]
}
diff --git a/src/internal/types/testdata/fixedbugs/issue57486.go b/src/internal/types/testdata/fixedbugs/issue57486.go
index ff9e3d1..f6ba1b6 100644
--- a/src/internal/types/testdata/fixedbugs/issue57486.go
+++ b/src/internal/types/testdata/fixedbugs/issue57486.go
@@ -17,13 +17,13 @@
func G2[T C2](t T) { _ = t == t }
func F1[V [2]any](v V) {
- _ = G1[V /* ERROR "V does not implement comparable" */]
+ _ = G1[V /* ERROR "V does not satisfy comparable" */]
_ = G1[[2]any]
_ = G1[int]
}
func F2[V [2]any](v V) {
- _ = G2[V /* ERROR "V does not implement C2" */]
- _ = G2[[ /* ERROR "\[2\]any does not implement C2 \(\[2\]any missing in int\)" */ 2]any]
+ _ = G2[V /* ERROR "V does not satisfy C2" */]
+ _ = G2[[ /* ERROR "\[2\]any does not satisfy C2 \(\[2\]any missing in int\)" */ 2]any]
_ = G2[int]
}
diff --git a/src/internal/types/testdata/spec/comparable.go b/src/internal/types/testdata/spec/comparable.go
index 03c8471..f407c35 100644
--- a/src/internal/types/testdata/spec/comparable.go
+++ b/src/internal/types/testdata/spec/comparable.go
@@ -11,16 +11,16 @@
func _[P comparable, Q ~int, R any]() {
_ = f1[int]
- _ = f1[T /* T does implement comparable */]
- _ = f1[any /* any does implement comparable */]
+ _ = f1[T /* T does satisfy comparable */]
+ _ = f1[any /* any does satisfy comparable */]
_ = f1[P]
_ = f1[Q]
- _ = f1[R /* ERROR R does not implement comparable */]
+ _ = f1[R /* ERROR R does not satisfy comparable */]
_ = f2[int]
- _ = f2[T /* T does implement comparable */]
- _ = f2[any /* any does implement comparable */]
+ _ = f2[T /* T does satisfy comparable */]
+ _ = f2[any /* any does satisfy comparable */]
_ = f2[P]
_ = f2[Q]
- _ = f2[R /* ERROR R does not implement comparable */]
+ _ = f2[R /* ERROR R does not satisfy comparable */]
}
diff --git a/src/internal/types/testdata/spec/comparable1.19.go b/src/internal/types/testdata/spec/comparable1.19.go
index c9c87e4..dc1c5fa 100644
--- a/src/internal/types/testdata/spec/comparable1.19.go
+++ b/src/internal/types/testdata/spec/comparable1.19.go
@@ -13,16 +13,16 @@
func _[P comparable, Q ~int, R any]() {
_ = f1[int]
- _ = f1[T /* ERROR T to implement comparable requires go1\.20 or later */]
- _ = f1[any /* ERROR any to implement comparable requires go1\.20 or later */]
+ _ = f1[T /* ERROR T to satisfy comparable requires go1\.20 or later */]
+ _ = f1[any /* ERROR any to satisfy comparable requires go1\.20 or later */]
_ = f1[P]
_ = f1[Q]
- _ = f1[R /* ERROR R does not implement comparable */]
+ _ = f1[R /* ERROR R does not satisfy comparable */]
_ = f2[int]
- _ = f2[T /* ERROR T to implement comparable requires go1\.20 or later */]
- _ = f2[any /* ERROR any to implement comparable requires go1\.20 or later */]
+ _ = f2[T /* ERROR T to satisfy comparable requires go1\.20 or later */]
+ _ = f2[any /* ERROR any to satisfy comparable requires go1\.20 or later */]
_ = f2[P]
_ = f2[Q]
- _ = f2[R /* ERROR R does not implement comparable */]
+ _ = f2[R /* ERROR R does not satisfy comparable */]
}
diff --git a/src/internal/types/testdata/spec/oldcomparable.go b/src/internal/types/testdata/spec/oldcomparable.go
index 9f6cf74..081d972 100644
--- a/src/internal/types/testdata/spec/oldcomparable.go
+++ b/src/internal/types/testdata/spec/oldcomparable.go
@@ -13,16 +13,16 @@
func _[P comparable, Q ~int, R any]() {
_ = f1[int]
- _ = f1[T /* ERROR T does not implement comparable */]
- _ = f1[any /* ERROR any does not implement comparable */]
+ _ = f1[T /* ERROR T does not satisfy comparable */]
+ _ = f1[any /* ERROR any does not satisfy comparable */]
_ = f1[P]
_ = f1[Q]
- _ = f1[R /* ERROR R does not implement comparable */]
+ _ = f1[R /* ERROR R does not satisfy comparable */]
_ = f2[int]
- _ = f2[T /* ERROR T does not implement comparable */]
- _ = f2[any /* ERROR any does not implement comparable */]
+ _ = f2[T /* ERROR T does not satisfy comparable */]
+ _ = f2[any /* ERROR any does not satisfy comparable */]
_ = f2[P]
_ = f2[Q]
- _ = f2[R /* ERROR R does not implement comparable */]
+ _ = f2[R /* ERROR R does not satisfy comparable */]
}
diff --git a/test/typeparam/mdempsky/8.dir/b.go b/test/typeparam/mdempsky/8.dir/b.go
index 84037bf..ef2637b 100644
--- a/test/typeparam/mdempsky/8.dir/b.go
+++ b/test/typeparam/mdempsky/8.dir/b.go
@@ -7,5 +7,5 @@
import "./a"
func init() {
- a.F[func()]() // ERROR "does not implement comparable"
+ a.F[func()]() // ERROR "does not satisfy comparable"
}
diff --git a/test/typeparam/mincheck.dir/main.go b/test/typeparam/mincheck.dir/main.go
index c9ca50a..6f85f9e 100644
--- a/test/typeparam/mincheck.dir/main.go
+++ b/test/typeparam/mincheck.dir/main.go
@@ -28,11 +28,11 @@
}
const want2 = "ay"
- if got := a.Min[string]("bb", "ay"); got != want2 { // ERROR "string does not implement"
+ if got := a.Min[string]("bb", "ay"); got != want2 { // ERROR "string does not satisfy"
panic(fmt.Sprintf("got %d, want %d", got, want2))
}
- if got := a.Min("bb", "ay"); got != want2 { // ERROR "string does not implement"
+ if got := a.Min("bb", "ay"); got != want2 { // ERROR "string does not satisfy"
panic(fmt.Sprintf("got %d, want %d", got, want2))
}
}
To view, visit change 460396. To unsubscribe, or for help writing mail filters, visit settings.