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
The return types of a function are being ignored when calling the map() function on empty objects.
Here's an example of how this functioned in 1.6 vs 1.8:
Julia 1.6:
julia>functionbar(v::Vector{Int})::AbstractArray{Int}fill(v[1], (1for _ in1:v[1])...)
end
bar (generic function with 1 method)
julia>map(bar, Vector{Int}[[1]])
1-element Vector{Vector{Int64}}:
[1]
julia>map(bar, Vector{Int}[[2]])
1-element Vector{Matrix{Int64}}:
[2]
julia>map(bar, Vector{Int}[])
AbstractArray{Int64, N} where N[]
Julia 1.8:
julia>functionbar(v::Vector{Int})::AbstractArray{Int}fill(v[1], (1for _ in1:v[1])...)
end
bar (generic function with 1 method)
julia>map(bar, Vector{Int}[[1]])
1-element Vector{Vector{Int64}}:
[1]
julia>map(bar, Vector{Int}[[2]])
1-element Vector{Matrix{Int64}}:
[2;;]
julia>map(bar, Vector{Int}[])
Any[]
This was due to the changes introduced where map functions call promote_typejoin_union and return Any instead of the given return type of the function.
This functionality was always the case for broadcast(), but now since map() is following this logic, the return types are ignored on empty objects.
The text was updated successfully, but these errors were encountered:
The return types of a function are being ignored when calling the
map()
function on empty objects.Here's an example of how this functioned in
1.6
vs1.8
:Julia 1.6:
Julia 1.8:
This was due to the changes introduced where map functions call promote_typejoin_union and return
Any
instead of the given return type of the function.This functionality was always the case for
broadcast()
, but now sincemap()
is following this logic, the return types are ignored on empty objects.The text was updated successfully, but these errors were encountered: