Skip to content

Commit c53262f

Browse files
authored
Change spec for SwitchStatement to include changes introduced in dlang/dmd#15656 (#3702)
* Change spec for SwitchStatement to include changes introduced in dlang/dmd#15656 * Update wording of SwitchStatement
1 parent 0e6a0b3 commit c53262f

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

spec/statement.dd

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,7 @@ $(H2 $(LEGACY_LNAME2 SwitchStatement, switch-statement, Switch Statement))
12531253

12541254
$(GRAMMAR
12551255
$(GNAME SwitchStatement):
1256-
$(D switch $(LPAREN)) $(EXPRESSION) $(D $(RPAREN)) $(PSSCOPE)
1256+
$(D switch $(LPAREN)) $(GLINK IfCondition) $(D $(RPAREN)) $(PSSCOPE)
12571257

12581258
$(GNAME CaseStatement):
12591259
$(D case) $(GLINK2 expression, ArgumentList) $(D :) $(PSSEMI_PSCURLYSCOPE_LIST)$(OPT)
@@ -1274,15 +1274,23 @@ $(GNAME StatementNoCaseNoDefault):
12741274
$(GLINK ScopeBlockStatement)
12751275
)
12761276

1277-
$(P $(I Expression) is evaluated.
1278-
If the type of $(I Expression) is an `enum`, it is
1277+
$(P The *Expression* from the $(I IfCondition) is evaluated.
1278+
If the type of the *Expression* is an `enum`, it is
12791279
(recursively) converted to its $(GLINK2 enum, EnumBaseType).
1280-
Then, if the type is an integral, $(I Expression) undergoes
1280+
Then, if the type is an integral, the *Expression* undergoes
12811281
$(DDSUBLINK spec/type, integer-promotions, Integer Promotions).
1282-
Then, the type of $(I Expression) must be either an integral or
1282+
Then, the type of the *Expression* must be either an integral or
12831283
a static or dynamic array of $(CODE char), $(CODE wchar), or $(CODE dchar).
12841284
)
12851285

1286+
$(P If an $(I Identifier) `=` prefix is provided, a variable is declared with that
1287+
name, initialized to the value and type of the *Expression*. Its scope
1288+
extends from when it is initialized to the end of the *ScopeStatement*.)
1289+
1290+
$(P If $(I TypeCtors) and/or a specific type is provided for *Identifier*, those
1291+
are used for the variable declaration which is initialized by an implicit
1292+
conversion from the value of the *Expression*.)
1293+
12861294
$(P The resulting value is
12871295
compared against each of the case expressions. If there is
12881296
a match, the corresponding case statement is transferred to.
@@ -1467,7 +1475,7 @@ $(H2 $(LEGACY_LNAME2 FinalSwitchStatement, final-switch-statement, Final Switch
14671475

14681476
$(GRAMMAR
14691477
$(GNAME FinalSwitchStatement):
1470-
$(D final switch $(LPAREN)) $(EXPRESSION) $(D $(RPAREN)) $(PSSCOPE)
1478+
$(D final switch $(LPAREN)) $(GLINK IfCondition) $(D $(RPAREN)) $(PSSCOPE)
14711479
)
14721480

14731481
$(P A final switch statement is just like a switch statement,

0 commit comments

Comments
 (0)