Skip to content

Reconsider string findprev semantics #49564

@Keno

Description

@Keno

We have (as described in #49547):

julia> findprev(==('x'), "x", 1)
1

julia> findprev(==('x'), "x", 2)

I don't think this makes much sense. It's also inconsistent with:

julia> findprev("x", "x", 1)
1:1

julia> findprev("x", "x", 2)

julia> findprev("ab", "ab", 2)
1:2

julia> findprev("ab", "ab", 3)
1:2

@KristofferC did some digging and found that I may have introduced this original behavior in 5e57c0b#diff-66843bd6e4b813dc28435a71b7a73a22f5fba6da4912e32eaf6d5f58745f8079R1269 and it has propagated from there since without a second thought. I think this might have been a bug. The condition makes sense for forward search, but I don't think it makes a lot of sense for reverse search. Nevertheless, it's been the behavior for many years, so we should probably decide carefully if and how to replace it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions