[Issue 16739] New: switch ignores case
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Nov 23 11:05:05 PST 2016
https://issues.dlang.org/show_bug.cgi?id=16739
Issue ID: 16739
Summary: switch ignores case
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: major
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: wendlec at tcd.ie
The following switch statement ignores a case when there's a smart quote
involved (and other characters like "`"). The behavior is identical with both
DMD (v2.072.0 and earlier) and LDC.
import std.array;
import std.conv;
import std.stdio;
void main()
{
auto tokens = to!(dchar[][])(["D"d, "’"d, "Addario"d, "'"d]);
// Or use this below:
//~ dstring[] tokens = ["D"d, "’"d, "Addario"d, "'"d];
while (!tokens.empty)
{
switch (tokens[0])
{
case "\u2019"d:
writeln("Apostrophe smart " ~ tokens[0]);
break;
case "\u0027"d:
writeln("Apostrophe straight " ~ tokens[0]);
break;
default:
writeln("Other " ~ tokens[0]);
break;
}
tokens = tokens[1..$];
}
}
Prints:
Other D
Apostrophe smart ’
Other Addario
Other '
Expected:
Other D
Apostrophe smart ’
Other Addario
Apostrophe straight ' <== expected
cf. http://forum.dlang.org/post/eocvkczgzetfoknikbpx@forum.dlang.org
--
More information about the Digitalmars-d-bugs
mailing list