]> Cypherpunks repositories - gostls13.git/commitdiff
go/types, types2: fix misleading internal comment
authorRobert Griesemer <gri@google.com>
Wed, 15 Oct 2025 18:27:17 +0000 (11:27 -0700)
committerRobert Griesemer <gri@google.com>
Wed, 15 Oct 2025 20:46:26 +0000 (13:46 -0700)
See also the discussion in #75885.

Change-Id: Ieb964ea6ee51600c0c08ecba0af50a1deb209a4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/712141
Reviewed-by: Mark Freeman <markfreeman@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
src/cmd/compile/internal/types2/decl.go
src/go/types/decl.go

index 4ebd945407075701add76c2ca30ca46362c6b1ad..22fccc15199e87c7de1c840778b2e9566e387bf5 100644 (file)
@@ -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]
index aef7f6ad0b90998007266d3552ed9e32cb866ac3..13d9d9ce57499ce92a4b1d1cff0e67376e3e8a50 100644 (file)
@@ -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]