Created attachment 1213
Patch to indexOf to avoid calling memchr
DMD 2.062
OS X
If the std.string.indexOf(Char[], dchar, CaseSensitive) method is called at
compile time with an ASCII dchar, it will fail:
/usr/share/dmd/src/phobos/std/string.d(345): Error: memchr cannot be
interpreted at compile time, because it has no available source code
Test case:
import std.stdio;
import std.string;
int index = indexOf("xyz", cast(dchar) 'x'); // Fails compile
int index1 = indexOf("xyz", cast(dstring) "x"); // Succeeds
void main() {
writeln("indexOf(\"xyz\", \"x\") = ", index);
}
Patch:
I've modified the string.d implementation to avoid calling memchr. In that
branch of the code, I have inserted a modified version of the case-insensitive
version of the search loop.
Diff file attached against the source included in the 2.0.62 distribution.
Regards,
Mike.
Comment #1 by diggsey — 2013-05-14T17:04:23Z
Coincidence - I just ran into the exact same problem with almost the exact same test you are using...