Bug 3376 – [tdpl] Multiple ranged case labels don't work
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Linux
Creation time
2009-10-08T12:00:00Z
Last change time
2015-06-09T05:14:54Z
Assigned to
nobody
Creator
andrei
Comments
Comment #0 by andrei — 2009-10-08T12:00:23Z
void classify(char c) {
write("You passed ");
switch (c) {
case '#':
writeln("a hash sign.");
break;
case '0': .. case '9':
writeln("a digit.");
break;
case 'A': .. case 'Z': case 'a' .. case 'z':
writeln("an ASCII character.");
break;
case '.', ',', ':', ';', '!', '?':
writeln("a punctuation mark.");
break;
default:
writeln("quite a character!");
break;
}
}
The code fails to compile. If I change the line:
case 'A': .. case 'Z': case 'a' .. case 'z':
to:
case 'A': .. case 'Z':
then it compiles.
Comment #1 by r.sagitario — 2009-10-16T15:09:11Z
> case 'A': .. case 'Z': case 'a' .. case 'z':
I'd say you have simply forgotten the colon after 'a'. With
> case 'A': .. case 'Z': case 'a': .. case 'z':
it compiles.
Comment #2 by andrei — 2009-10-16T15:15:41Z
(In reply to comment #1)
> > case 'A': .. case 'Z': case 'a' .. case 'z':
>
> I'd say you have simply forgotten the colon after 'a'. With
>
> > case 'A': .. case 'Z': case 'a': .. case 'z':
>
> it compiles.
Ouch. This is rather ironic in wake of the fact that I preached the helpfulness of that ':'. Thanks, and apologies to everyone for the distraction.