[Issue 20783] New: std.string.lastIndexOf doesn't work correctly in CTFE
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Apr 28 11:55:47 UTC 2020
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 at puremagic.com
Reporter: chalucha at 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.
--
More information about the Digitalmars-d-bugs
mailing list