Bug 20783 – std.string.lastIndexOf doesn't work correctly in CTFE

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
All
Creation time
2020-04-28T11:55:47Z
Last change time
2020-04-29T10:18:46Z
Keywords
pull
Assigned to
No Owner
Creator
Tomáš Chaloupka

Comments

Comment #0 by chalucha — 2020-04-28T11:55:47Z
``` 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.
Comment #1 by dlang-bot — 2020-04-29T00:55:13Z
@wolframw created dlang/phobos pull request #7465 "Fix Issue 20783 - std.string.lastIndexOf doesn't work correctly in CTFE" fixing this issue: - Fix Issue 20783 - std.string.lastIndexOf doesn't work correctly in CTFE https://github.com/dlang/phobos/pull/7465
Comment #2 by dlang-bot — 2020-04-29T10:18:46Z
dlang/phobos pull request #7465 "Fix Issue 20783 - std.string.lastIndexOf doesn't work correctly in CTFE" was merged into master: - c57990ceda8e0108554abde9eed0fc04e4041529 by wolframw: Fix Issue 20783 - std.string.lastIndexOf doesn't work correctly in CTFE https://github.com/dlang/phobos/pull/7465