diff --git a/src/cmd/compile/internal/types2/decl.go b/src/cmd/compile/internal/types2/decl.go index 4ebd9454070..22fccc15199 100644 --- a/src/cmd/compile/internal/types2/decl.go +++ b/src/cmd/compile/internal/types2/decl.go @@ -575,11 +575,8 @@ func (check *Checker) typeDecl(obj *TypeName, tdecl *syntax.TypeDecl, def *TypeN named.underlying = Typ[Invalid] } - // Disallow a lone type parameter as the RHS of a type declaration (go.dev/issue/45639). - // We don't need this restriction anymore if we make the underlying type of a type - // parameter its constraint interface: if the RHS is a lone type parameter, we will - // use its underlying type (like we do for any RHS in a type declaration), and its - // underlying type is an interface and the type declaration is well defined. + // spec: "In a type definition the given type cannot be a type parameter." + // (See also go.dev/issue/45639.) if isTypeParam(rhs) { check.error(tdecl.Type, MisplacedTypeParam, "cannot use a type parameter as RHS in type declaration") named.underlying = Typ[Invalid] diff --git a/src/go/types/decl.go b/src/go/types/decl.go index aef7f6ad0b9..13d9d9ce574 100644 --- a/src/go/types/decl.go +++ b/src/go/types/decl.go @@ -657,11 +657,8 @@ func (check *Checker) typeDecl(obj *TypeName, tdecl *ast.TypeSpec, def *TypeName named.underlying = Typ[Invalid] } - // Disallow a lone type parameter as the RHS of a type declaration (go.dev/issue/45639). - // We don't need this restriction anymore if we make the underlying type of a type - // parameter its constraint interface: if the RHS is a lone type parameter, we will - // use its underlying type (like we do for any RHS in a type declaration), and its - // underlying type is an interface and the type declaration is well defined. + // spec: "In a type definition the given type cannot be a type parameter." + // (See also go.dev/issue/45639.) if isTypeParam(rhs) { check.error(tdecl.Type, MisplacedTypeParam, "cannot use a type parameter as RHS in type declaration") named.underlying = Typ[Invalid]