File tree 1 file changed +29
-2
lines changed
1 file changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -2511,12 +2511,12 @@ <h4 id="Alias_declarations">Alias declarations</h4>
2511
2511
</ p >
2512
2512
2513
2513
< pre class ="ebnf ">
2514
- AliasDecl = identifier "=" Type .
2514
+ AliasDecl = identifier [ TypeParameters ] "=" Type .
2515
2515
</ pre >
2516
2516
2517
2517
< p >
2518
2518
Within the < a href ="#Declarations_and_scope "> scope</ a > of
2519
- the identifier, it serves as an < i > alias</ i > for the type.
2519
+ the identifier, it serves as an < i > alias</ i > for the given type.
2520
2520
</ p >
2521
2521
2522
2522
< pre >
@@ -2526,6 +2526,24 @@ <h4 id="Alias_declarations">Alias declarations</h4>
2526
2526
)
2527
2527
</ pre >
2528
2528
2529
+ < p >
2530
+ If the alias declaration specifies < a href ="#Type_parameter_declarations "> type parameters</ a >
2531
+ [< a href ="#Go_1.24 "> Go 1.24</ a > ], the type name denotes a < i > generic alias</ i > .
2532
+ Generic aliases must be < a href ="#Instantiations "> instantiated</ a > when they
2533
+ are used.
2534
+ </ p >
2535
+
2536
+ < pre >
2537
+ type set[P comparable] = map[P]bool
2538
+ </ pre >
2539
+
2540
+ < p >
2541
+ In an alias declaration the given type cannot be a type parameter.
2542
+ </ p >
2543
+
2544
+ < pre >
2545
+ type A[P any] = P // illegal: P is a type parameter
2546
+ </ pre >
2529
2547
2530
2548
< h4 id ="Type_definitions "> Type definitions</ h4 >
2531
2549
@@ -8687,6 +8705,15 @@ <h4 id="Go_1.23">Go 1.23</h4>
8687
8705
function as range expression.
8688
8706
</ li >
8689
8707
</ ul >
8708
+
8709
+ < h4 id ="Go_1.24 "> Go 1.24</ h4 >
8710
+ < ul >
8711
+ < li >
8712
+ An < a href ="#Alias_declarations "> alias declaration</ a > may declare
8713
+ < a href ="#Type_parameter_declarations "> type parameters</ a > .
8714
+ </ li >
8715
+ </ ul >
8716
+
8690
8717
< h3 id ="Type_unification_rules "> Type unification rules</ h3 >
8691
8718
8692
8719
< p >
You can’t perform that action at this time.
0 commit comments