Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions base/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,15 @@ end
@noinline throwdm(axdest, axsrc) =
throw(DimensionMismatch("destination axes $axdest are not compatible with source axes $axsrc"))

function restart_copyto_nonleaf!(newdest, dest, bc, val, I, iter, state, count)
# Function barrier that makes the copying to newdest type stable
for II in Iterators.take(iter, count)
newdest[II] = dest[II]
end
newdest[I] = val
return copyto_nonleaf!(newdest, bc, iter, state, count+1)
end

function copyto_nonleaf!(dest, bc::Broadcasted, iter, state, count)
T = eltype(dest)
while true
Expand All @@ -976,11 +985,7 @@ function copyto_nonleaf!(dest, bc::Broadcasted, iter, state, count)
# This element type doesn't fit in dest. Allocate a new dest with wider eltype,
# copy over old values, and continue
newdest = Base.similar(dest, promote_typejoin(T, typeof(val)))
for II in Iterators.take(iter, count)
newdest[II] = dest[II]
end
newdest[I] = val
return copyto_nonleaf!(newdest, bc, iter, state, count+1)
return restart_copyto_nonleaf!(newdest, dest, bc, val, I, iter, state, count)
end
count += 1
end
Expand Down