Minimal working example (for both v1.0.3 and v1.1.0):
import Base: occursin
function occursin(needle::String, haystack::Union{String,Missing})
if !ismissing(haystack)
return occursin(needle, haystack)
else
return false
end
end
@show occursin("foo", missing) # false
@show occursin("foo", "foobar") # segmentation fault:11 in v1.0.3, bus error: 10 in v1.1.0
Seems to me that this is a bug. However, I’m wondering if there is something wrong as well when trying to extend the function occursin
in this way. If I extend the function in the following way, there is no segmentation fault:
import Base: occursin
function occursin(needle::Union{AbstractString,Regex,AbstractChar}, haystack::Union{AbstractString,Missing})
if !ismissing(haystack)
return occursin(needle, haystack)
else
return false
end
end
@show occursin("foo", missing) # false
@show occursin("foo", "foobar") # true