Skip to content

Bugs in search -> findfirst deprecation and Compat #26145

@tbole

Description

@tbole

In 0.7 search has been deprecated in favor of findfirst / findlast, however these behave differently than search in some cases, e.g. if a value is not found.

julia> search("x",'y')   # returns 0 in 0.6, nothing in 0.7
0

Another error occurs with 0.6 and Compat when using Compat.findfirst and passing Unicode strings.

julia> Compat.findfirst("uniçº∂e",'x')  # works on 0.7, fails on 0.6
ERROR: UnicodeError: invalid character index 5 (0xa7 is a continuation byte)
Stacktrace:
 [1] slow_utf8_next(::Ptr{UInt8}, ::UInt8, ::Int64, ::Int64) at ./strings/string.jl:172
 [2] next at ./strings/string.jl:204 [inlined]
 [3] getindex(::String, ::Int64) at ./strings/basic.jl:32
 [4] findnext(::String, ::Char, ::Int64) at ./array.jl:1262
 [5] findfirst(::String, ::Char) at ./array.jl:1288
 [6] findfirst(::String, ::Vararg{Any,N} where N) at /home/tbole/.julia/v0.6/Compat/src/Compat.jl:1589

Metadata

Metadata

Assignees

No one assigned

    Labels

    deprecationThis change introduces or involves a deprecationsearch & findThe find* family of functions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions