@@ -69,6 +69,25 @@ $(H2 $(LNAME2 named_enums, Named Enums))
69
69
enum X { A, B, C } // named enum
70
70
---
71
71
72
+ $(LEGACY_LNAME2 enum_default_initializer, enum_variables)
73
+
74
+ $(P A variable can be of named enum type.
75
+ Its default initializer is the first member defined for the enum type.
76
+ )
77
+
78
+ $(SPEC_RUNNABLE_EXAMPLE_RUN
79
+ ------
80
+ enum X { A = 3, B, C }
81
+
82
+ X x;
83
+ assert(x == X.A);
84
+ x |= X.B;
85
+ assert(x & X.A);
86
+ ------
87
+ )
88
+
89
+ $(P The result type of a binary operation on a named enum is defined
90
+ $(DDSUBLINK spec/type, enum-ops, here).)
72
91
73
92
$(P If the $(GLINK EnumBaseType) is not explicitly set, and the first
74
93
$(I EnumMember) has an *AssignExpression*, it is set to the type of that
@@ -80,10 +99,10 @@ $(H2 $(LNAME2 named_enums, Named Enums))
80
99
81
100
$(SPEC_RUNNABLE_EXAMPLE_FAIL
82
101
-------------------
83
- int i;
84
-
85
102
enum Foo { E }
103
+
86
104
Foo f;
105
+ int i;
87
106
i = f; // OK
88
107
f = i; // error
89
108
f = cast(Foo)i; // OK
@@ -92,7 +111,11 @@ f = Foo.E; // OK
92
111
-------------------
93
112
)
94
113
95
- $(P A named enum member does not have an individual $(I Type).)
114
+ $(P A named enum member cannot declare its own $(I Type).)
115
+
116
+ $(P See also: $(DDSUBLINK spec/statement, final-switch-statement, `final switch`) on a named enum.)
117
+
118
+ $(H3 $(LNAME2 member_values, Enum Member Values))
96
119
97
120
$(P The value of an $(GLINK EnumMember) is given by its *AssignExpression* if present.
98
121
If there is no *AssignExpression* and it is the first $(I EnumMember),
@@ -153,27 +176,6 @@ enum E : C
153
176
writeln(X.init); // error: enum X is opaque and has no default initializer
154
177
---
155
178
156
- $(H3 $(LEGACY_LNAME2 enum_default_initializer, enum_variables, Enum Variables))
157
-
158
- $(P A variable can be of named enum type.
159
- The default initializer is the first member defined for the enum type.
160
- )
161
-
162
- $(SPEC_RUNNABLE_EXAMPLE_RUN
163
- ------
164
- enum X { A = 3, B, C }
165
- X x;
166
- assert(x == X.A);
167
- x |= X.B;
168
- assert(x & X.A);
169
- ------
170
- )
171
-
172
- $(P The result type of a binary operation performed when the operands have
173
- different types is defined $(DDSUBLINK spec/type, enum-ops, here).)
174
-
175
- $(P See also: $(DDSUBLINK spec/statement, final-switch-statement, `final switch`).)
176
-
177
179
$(H3 $(LNAME2 enum_properties, Enum Properties))
178
180
179
181
$(P Enum properties only exist for named enums.
0 commit comments