Bug with std.string.indexOf and case sensivity

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri May 16 18:08:47 PDT 2014


On 05/16/2014 05:55 PM, Alexandre L. wrote:

 >
 >> I'll try to fetch git head and get everything working.
 >>
 >> Alexandre L.
 >
 > Nevermind that.
 > For some reasons, the bug was happening when my main.d file looked like
 > this:
 >
 > import std.stdio;
 > //import std.string; // will work when imported
 >
 > int main()
 > {
 >   string str = "Les chemises";
 >   // doesnt work
 >   write(std.string.indexOf(str, "Les", CaseSensivity.yes));

I can't explain right now how it happens but I suspect that there is an 
implicit conversion issue and your enum literal is taken as the startIdx 
parameter of one of the many overloads of indexOf.

Ali

 >   return 0;
 > }
 >
 > ---
 > While it works when importing std.string. Note that I was using exactly
 > the same enum (at least, I thought ?) than std.string
 >
 > enum CaseSensivity { no, yes }
 >
 > Whatever, it works now. I just need to don't forget to import std.string.
 >
 > Alexandre L.



More information about the Digitalmars-d-learn mailing list