Skip to content

Commit

Permalink
Ensure inference of Bool when array type is Any (#45452)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tokazama committed Jun 1, 2022
1 parent cbcb359 commit ab4c8cf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2546,7 +2546,7 @@ function filter(f, a::Array{T, N}) where {T, N}
b = Vector{T}(undef, length(a))
for ai in a
@inbounds b[j] = ai
j = ifelse(f(ai), j+1, j)
j = ifelse(f(ai)::Bool, j+1, j)
end
resize!(b, j-1)
sizehint!(b, length(b))
Expand All @@ -2561,7 +2561,7 @@ function filter(f, a::AbstractArray)
for idx in eachindex(a)
@inbounds idxs[j] = idx
ai = @inbounds a[idx]
j = ifelse(f(ai), j+1, j)
j = ifelse(f(ai)::Bool, j+1, j)
end
resize!(idxs, j-1)
res = a[idxs]
Expand Down Expand Up @@ -2591,7 +2591,7 @@ function filter!(f, a::AbstractVector)
j = firstindex(a)
for ai in a
@inbounds a[j] = ai
j = ifelse(f(ai), nextind(a, j), j)
j = ifelse(f(ai)::Bool, nextind(a, j), j)
end
j > lastindex(a) && return a
if a isa Vector
Expand Down

0 comments on commit ab4c8cf

Please sign in to comment.