On 11/23/16 11:28 AM, Chris wrote:
Only one of the two cases is considered. What am I doing wrong?

`
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 '

I would have expected:

Other D
Apostrophe smart ’
Other Addario
Apostrophe straight '  <== expected

I tested this locally with different ideas. This definitely looks like a codegen bug.

I was able to reduce it to:

void main()
{
    switch("'"d)
    {
    case "'"d:
        writeln("a");
        break;
    case "’"d:
        writeln("b");
        break;
    default:
        writeln("default");
    }
}

prints "default"

What seems to fix it is removing the case statement for the "smart apostrophe". So I'd look there for where the bug is triggering.

-Steve

Reply via email to