Bug 9529 – Switch Statement grammar bug for the chain of case statements
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-02-17T18:28:51Z
Last change time
2021-07-08T23:04:04Z
Keywords
rejects-valid, spec
Assigned to
No Owner
Creator
Kenji Hara
Comments
Comment #0 by k.hara.pg — 2013-02-17T18:28:51Z
Currently the chain of case statement is not allowed in grammar.
void main() {
int c;
switch (c) {
case 1:
case 2: // chain
break;
default: break;
}
}
But it is no sense. Because it is just equivalent with:
switch (c) {
case 1 : .. case 2:
break;
http://dlang.org/statement.html#SwitchStatement
--------
SwitchStatement:
switch ( Expression ) ScopeStatement
CaseStatement:
case ArgumentList : ScopeStatementList
CaseRangeStatement:
case FirstExp : .. case LastExp : ScopeStatementList
FirstExp:
AssignExpression
LastExp:
AssignExpression
DefaultStatement:
default : ScopeStatementList
ScopeStatementList:
StatementListNoCaseNoDefault
StatementListNoCaseNoDefault:
StatementNoCaseNoDefault
StatementNoCaseNoDefault StatementListNoCaseNoDefault
StatementNoCaseNoDefault:
;
NonEmptyStatementNoCaseNoDefault
ScopeBlockStatement
--------
Comment #1 by andrej.mitrovich — 2014-04-22T23:40:29Z
This seems trivial but I can't work with grammars. Can anyone fix this up if it still needs fixing?
Comment #2 by bugzilla — 2019-12-21T13:20:30Z
*** Issue 13326 has been marked as a duplicate of this issue. ***