You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In array.jl the function filter is implemented using map filter(f, As::AbstractArray) = As[map(f, As)::AbstractArray{Bool}]
but map does not change the elementtype of the AbstractArray if the AbstractArray is empty.
map(n-> true, 1:2) results in Array{Bool,1}
but map(n-> true, 1:0) results in Array{Int64,1} , which causes the problem in filter
Is this the expected behaviour of map? Edit: seems to be related to #210, map infers the type from the first element, so it can not get the right type.
Consider the code:
filter(n -> true, collect(1:0))
this returns a 0-element array. However if I don't collect the iterator into an array:
filter(n -> true, 1:0)
I get the error
Error: TypeError: typeassert: expected AbstractArray{Bool, N}, got Array{Int64, 1} in filter at array.jl:923
It seems like this should also return a 0-element array, since if the iterator is non empty, e.g.
filter(n -> true, 1:2)
I get the two element array
[1,2]
.The text was updated successfully, but these errors were encountered: