From: Robert Griesemer
Date: Tue, 1 Oct 2024 22:03:25 +0000 (-0700)
Subject: spec: document that alias declarations can have type parameters with 1.24
X-Git-Tag: go1.24rc1~776
X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=630d4fb600ae309476c87a4ca0e29b60425bc0c1;p=gostls13.git
spec: document that alias declarations can have type parameters with 1.24
For #46477.
Change-Id: Id02d8f67fe82228bab3f26b1cb4ebd6ee67c4634
Reviewed-on: https://go-review.googlesource.com/c/go/+/616816
Reviewed-by: Ian Lance Taylor
Auto-Submit: Robert Griesemer
Reviewed-by: Rob Pike
Reviewed-by: Robert Griesemer
TryBot-Bypass: Robert Griesemer
---
diff --git a/doc/go_spec.html b/doc/go_spec.html
index 50cb718395..579e254790 100644
--- a/doc/go_spec.html
+++ b/doc/go_spec.html
@@ -2511,12 +2511,12 @@ An alias declaration binds an identifier to the given type
-AliasDecl = identifier "=" Type .
+AliasDecl = identifier [ TypeParameters ] "=" Type .
Within the scope of
-the identifier, it serves as an alias for the type.
+the identifier, it serves as an alias for the given type.
@@ -2526,6 +2526,24 @@ type (
)
+
+If the alias declaration specifies type parameters
+[Go 1.24], the type name denotes a generic alias.
+Generic aliases must be instantiated when they
+are used.
+
+
+
+type set[P comparable] = map[P]bool
+
+
+
+In an alias declaration the given type cannot be a type parameter.
+
+
+
+type A[P any] = P // illegal: P is a type parameter
+
Type definitions
@@ -8687,6 +8705,15 @@ integer values from zero to an upper limit.
function as range expression.
+
+Go 1.24
+
+
Type unification rules