Bug 10078 – std.string.indexOf(Char[], dchar, CaseSensitive) fails at compile time

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-05-13T16:44:00Z
Last change time
2013-07-16T18:07:44Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
michael

Attachments

IDFilenameSummaryContent-TypeSize
1213string.d.diffPatch to indexOf to avoid calling memchrapplication/octet-stream636

Comments

Comment #0 by michael — 2013-05-13T16:44:16Z
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...
Comment #2 by michael — 2013-05-17T04:17:51Z
I've created a pull request, in case it helps: https://github.com/D-Programming-Language/phobos/pull/1293 Mike.
Comment #3 by github-bugzilla — 2013-07-16T18:00:21Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/4bafa5735ff54dca7ae386599ab1c2be87b72cb8 fix Issue 10078 - std.string.indexOf fails at compile time https://github.com/D-Programming-Language/phobos/commit/8410f983b485c3cd7c08ca82221405b2937c8e70 Merge pull request #1417 from dawgfoto/fix10078 fix Issue 10078 - std.string.indexOf fails at compile time