We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 94e905c commit c75bf3cCopy full SHA for c75bf3c
src/setindex.jl
@@ -3,12 +3,14 @@ Base.@propagate_inbounds function setindex(args...)
3
end
4
5
Base.@propagate_inbounds function setindex(xs::AbstractArray, v, I...)
6
- T = promote_type(eltype(xs), typeof(v))
+ # we need to distinguish between scalar and sliced assignment
7
+ I_normalized = Base.to_indices(xs, I)
8
+ T = promote_type(eltype(xs), I_normalized isa Tuple{Vararg{Integer}} ? typeof(v) : eltype(v))
9
ys = similar(xs, T)
10
if eltype(xs) !== Union{}
11
copy!(ys, xs)
12
- ys[I...] = v
13
+ ys[I_normalized...] = v
14
return ys
15
16
0 commit comments