Skip to content

Commit 940e78d

Browse files
WalterBrightdlang-bot
authored andcommitted
with statement now does enum expressions
1 parent e04fa50 commit 940e78d

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

spec/statement.dd

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1688,20 +1688,43 @@ $(GNAME WithStatement):
16881688
$(D with) $(D $(LPAREN)) $(GLINK2 template, TemplateInstance) $(D $(RPAREN)) $(PSSCOPE)
16891689
)
16901690

1691-
where *Expression* evaluates to a class reference or struct
1692-
instance.
1691+
where *Expression* evaluates to one of:
1692+
1693+
$(UL
1694+
$(LI a class reference)
1695+
$(LI a struct instance)
1696+
$(LI an enum instance)
1697+
$(LI a pointer to one of the above)
1698+
)
1699+
16931700
Within the with body the referenced object is searched first for
16941701
identifier symbols.
16951702

1703+
---
1704+
enum E { A, B }
1705+
1706+
void test(E e)
1707+
{
1708+
with (e) // affects the switch statement
1709+
switch (e)
1710+
{
1711+
case A: // no need for E.A
1712+
case B:
1713+
default:
1714+
break;
1715+
}
1716+
}
1717+
---
1718+
16961719
$(P Below, if `ident` is a member of the type of `expression`, the $(I WithStatement):)
16971720

1698-
--------------
1721+
---
16991722
with (expression)
17001723
{
17011724
...
17021725
ident;
17031726
}
1704-
--------------
1727+
---
17051728

17061729
is semantically equivalent to:
17071730

0 commit comments

Comments
 (0)