Base.@propagate_inbounds function setindex(xs::AbstractArray, v, I...)
T = promote_type(eltype(xs), typeof(v))
ys = similar(xs, T)
if isbitstype(T)
copy!(ys, xs)
elseif eltype(xs) !== Union{}
for index in CartesianIndices(xs)
if isassigned(xs, Tuple(index)...)
ys[index] = xs[index]
end
end
end
ys[I...] = v
return ys
end
? Seems sub-optimal though.
This is not an urgent issue to resolve for our sake, but figured I'd at least raise it here for now. In the meantime (and this is what we'll do anyways as it aligns better with the behavior we want) one can use BangBang.@set!! which uses BangBang.prefermutation instead of identity in setmacro.
It correctly works when
eltype
isbitstype
since then you don't end up withundef
but instead an "unitialized" value, for exampleMaybe the way to go is:
? Seems sub-optimal though.
This is not an urgent issue to resolve for our sake, but figured I'd at least raise it here for now. In the meantime (and this is what we'll do anyways as it aligns better with the behavior we want) one can use
BangBang.@set!!
which usesBangBang.prefermutation
instead ofidentity
insetmacro
.