Skip to content

Commit 3ec714d

Browse files
committed
fix: missing scalar indexing check for setindex
1 parent 12531c9 commit 3ec714d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/TracedRArray.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,17 @@ function Base.getindex(a::WrappedTracedRArray, indices...)
172172
return getindex(ancestor(a), TracedUtils.get_ancestor_indices(a, indices...)...)
173173
end
174174

175+
function maybe_assert_scalar_setindexing(
176+
::TracedRArray{T,N}, ::Vararg{Union{Int,TracedRNumber{Int}},N}
177+
) where {T,N}
178+
GPUArraysCore.assertscalar("setindex!(::TracedRArray, v, ::Vararg{Int, N})")
179+
end
180+
181+
maybe_assert_scalar_setindexing(args...) = nothing
182+
175183
function Base.setindex!(a::TracedRArray{T,N}, v, indices::Vararg{Any,N}) where {T,N}
184+
maybe_assert_scalar_setindexing(a, indices...)
185+
176186
indices = map(enumerate(indices)) do (idx, i)
177187
i isa Colon && return 1:size(a, idx)
178188
i isa CartesianIndex && return Tuple(i)

0 commit comments

Comments
 (0)