julia> map!(identity, [], [1,2,3])

This is problematic because one might assume incorrectly that it'd push! to the destination argument. According to the docstring, the destination must be longer than than the smallest collection being mapped over:

  Like map, but stores the result in destination rather than a new collection. destination must be at least as large as the smallest collection.

I think we could avoid some silent surprises if this errored (as the docstring implies)


Technically this should probably be considered a bug fix, but I wonder if this might break any packages. It definitely seems like the kind of thing that might be used (intentionally or unintentionally) by some package in the wild.

Another example, just to show how naturally it can arise (i.e. not just for empty vectors).

julia> a = zeros(2);

julia> map!(x -> x + 1, a, 1:3)
2-element Vector{Float64}:
© 2022 - All rights reserved.