Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/dmd/parse.d
Original file line number Diff line number Diff line change
Expand Up @@ -6202,14 +6202,16 @@ LagainStc:
AST.Expressions cases; // array of Expression's
AST.Expression last = null;

while (1)
nextToken();
do
{
nextToken();
exp = parseAssignExp();
cases.push(exp);
if (token.value != TOK.comma)
break;
nextToken(); //comma
}
while (token.value != TOK.colon && token.value != TOK.endOfFile);
check(TOK.colon);

/* case exp: .. case last:
Expand Down
12 changes: 12 additions & 0 deletions test/compilable/testparse.d
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,15 @@ void testIfConditionWithSTCandType()
// https://issues.dlang.org/show_bug.cgi?id=20791
extern(C++, "foo", )
struct S {}

/***************************************************/
// https://issues.dlang.org/show_bug.cgi?id=22019
void test22019()
{
final switch (1)
{
case 1,:
case 2,3,:
break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a test that verifies the error messages for case ,: and case :?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, though I did specifically avoid using check(TOK.comma) to avoid a bad error message.

}
}