www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20783] New: std.string.lastIndexOf doesn't work correctly in

https://issues.dlang.org/show_bug.cgi?id=20783

          Issue ID: 20783
           Summary: std.string.lastIndexOf doesn't work correctly in CTFE
           Product: D
           Version: D2
          Hardware: x86_64
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: chalucha gmail.com

```
pragma(msg, "aa".lastIndexOf("ab"));
```

Returns 0 instead of -1.

Problem seems to be with:
https://github.com/dlang/phobos/blob/ffca395ed2e9fd31cdb8e3e67adb8ddfba2607ac/std/string.d#L1345

as it continues foreach loop that should be stopped and instead upper for loop
should continue with next character.

--
Apr 28