type (
_[T interface{ *T } ] struct{} // ok
_[T interface{ int | *T } ] struct{} // ok
- _[T interface{ T /* ERROR cannot embed a type parameter */ } ] struct{}
- _[T interface{ ~T /* ERROR cannot embed a type parameter */ } ] struct{}
- _[T interface{ int|T /* ERROR cannot embed a type parameter */ }] struct{}
+ _[T interface{ T /* ERROR term cannot be a type parameter */ } ] struct{}
+ _[T interface{ ~T /* ERROR type in term ~T cannot be a type parameter */ } ] struct{}
+ _[T interface{ int|T /* ERROR term cannot be a type parameter */ }] struct{}
)
// Multiple embedded union elements are intersected. The order in which they
package p
type T[P any] interface{
- P // ERROR cannot embed a type parameter
+ P // ERROR term cannot be a type parameter
}
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" */ }
+ _[P any] interface{ P /* ERROR term cannot be a type parameter */ }
+ _[P any] interface{ ~P /* ERROR type in term ~P cannot be a type parameter */ }
+ _[P any] interface{ int | P /* ERROR term cannot be a type parameter */ }
+ _[P any] interface{ int | ~P /* ERROR type in term ~P cannot be 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" */ }
+ _[P any] interface{ P /* ERROR term cannot be a type parameter */ }
+ _[P any] interface{ ~P /* ERROR type in term ~P cannot be a type parameter */ }
+ _[P any] interface{ int | P /* ERROR term cannot be a type parameter */ }
+ _[P any] interface{ int | ~P /* ERROR type in term ~P cannot be 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" */ }
+ _ interface{ P /* ERROR term cannot be a type parameter */ }
+ _ interface{ ~P /* ERROR type in term ~P cannot be a type parameter */ }
+ _ interface{ int | P /* ERROR term cannot be a type parameter */ }
+ _ interface{ int | ~P /* ERROR type in term ~P cannot be 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" */ }]() {}
+func _[P any, Q interface{ P /* ERROR term cannot be a type parameter */ }]() {}
+func _[P any, Q interface{ ~P /* ERROR type in term ~P cannot be a type parameter */ }]() {}
+func _[P any, Q interface{ int | P /* ERROR term cannot be a type parameter */ }]() {}
+func _[P any, Q interface{ int | ~P /* ERROR type in term ~P cannot be a type parameter */ }]() {}
// simply use its underlying type (like we do for other named, embedded interfaces),
// and since the underlying type is an interface the embedding is well defined.
if isTypeParam(typ) {
- check.error(x, "cannot embed a type parameter")
+ if tilde {
+ check.errorf(x, "type in term %s cannot be a type parameter", tx)
+ } else {
+ check.error(x, "term cannot be a type parameter")
+ }
typ = Typ[Invalid]
}
term := NewTerm(tilde, typ)
type (
_[T interface{ *T } ] struct{} // ok
_[T interface{ int | *T } ] struct{} // ok
- _[T interface{ T /* ERROR cannot embed a type parameter */ } ] struct{}
- _[T interface{ ~T /* ERROR cannot embed a type parameter */ } ] struct{}
- _[T interface{ int|T /* ERROR cannot embed a type parameter */ }] struct{}
+ _[T interface{ T /* ERROR term cannot be a type parameter */ } ] struct{}
+ _[T interface{ ~T /* ERROR type in term ~T cannot be a type parameter */ } ] struct{}
+ _[T interface{ int|T /* ERROR term cannot be a type parameter */ }] struct{}
)
// Multiple embedded union elements are intersected. The order in which they
package p
type T[P any] interface{
- P // ERROR cannot embed a type parameter
+ P // ERROR term cannot be a type parameter
}
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" */ }
+ _[P any] interface{ P /* ERROR term cannot be a type parameter */ }
+ _[P any] interface{ ~P /* ERROR type in term ~P cannot be a type parameter */ }
+ _[P any] interface{ int | P /* ERROR term cannot be a type parameter */ }
+ _[P any] interface{ int | ~P /* ERROR type in term ~P cannot be 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" */ }
+ _[P any] interface{ P /* ERROR term cannot be a type parameter */ }
+ _[P any] interface{ ~P /* ERROR type in term ~P cannot be a type parameter */ }
+ _[P any] interface{ int | P /* ERROR term cannot be a type parameter */ }
+ _[P any] interface{ int | ~P /* ERROR type in term ~P cannot be 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" */ }
+ _ interface{ P /* ERROR term cannot be a type parameter */ }
+ _ interface{ ~P /* ERROR type in term ~P cannot be a type parameter */ }
+ _ interface{ int | P /* ERROR term cannot be a type parameter */ }
+ _ interface{ int | ~P /* ERROR type in term ~P cannot be 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" */ }]() {}
+func _[P any, Q interface{ P /* ERROR term cannot be a type parameter */ }]() {}
+func _[P any, Q interface{ ~P /* ERROR type in term ~P cannot be a type parameter */ }]() {}
+func _[P any, Q interface{ int | P /* ERROR term cannot be a type parameter */ }]() {}
+func _[P any, Q interface{ int | ~P /* ERROR type in term ~P cannot be a type parameter */ }]() {}
// simply use its underlying type (like we do for other named, embedded interfaces),
// and since the underlying type is an interface the embedding is well defined.
if isTypeParam(typ) {
- check.error(x, _MisplacedTypeParam, "cannot embed a type parameter")
+ if tilde {
+ check.errorf(x, _MisplacedTypeParam, "type in term %s cannot be a type parameter", tx)
+ } else {
+ check.error(x, _MisplacedTypeParam, "term cannot be a type parameter")
+ }
typ = Typ[Invalid]
}
term := NewTerm(tilde, typ)