@@ -3004,13 +3004,25 @@ Base.@propagate_inbounds function _getindex(arr::BasicSymbolic{T}, idxs::Union{B
3004
3004
sh = shape (arr)
3005
3005
type = promote_symtype (getindex, symtype (arr), symtype .(idxs)... )
3006
3006
newshape = promote_shape (getindex, sh, shape .(idxs)... )
3007
- for (oldidx, idx) in zip (Iterators. drop (args, 1 ), idxs)
3008
- if idx isa Colon
3007
+ idxs_i = 1
3008
+ for oldidx in Iterators. drop (args, 1 )
3009
+ oldidx_sh = shape (oldidx)
3010
+ if ! _is_array_shape (oldidx_sh)
3011
+ push! (newargs, oldidx)
3012
+ continue
3013
+ end
3014
+ idx = idxs[idxs_i]
3015
+ idxs_i += 1
3016
+ # special case when `oldidx` is `Colon()`
3017
+ if length (oldidx_sh) == 1 && oldidx_sh[1 ] == 1 : 0
3018
+ push! (newargs, Const {T} (idx))
3019
+ elseif idx isa Colon
3009
3020
push! (newargs, oldidx)
3010
3021
else
3011
3022
push! (newargs, Const {T} (unwrap_const (oldidx)[idx]))
3012
3023
end
3013
3024
end
3025
+ @assert idxs_i == length (idxs) + 1
3014
3026
return BSImpl. Term {T} (f, newargs; type, shape = newshape)
3015
3027
end
3016
3028
_ => nothing
@@ -3121,6 +3133,15 @@ end
3121
3133
function Base. getindex (x:: AbstractArray , i1, idx:: BasicSymbolic{T} , idxs... ) where {T}
3122
3134
getindex (Const {T} (x), i1, idx, idxs... )
3123
3135
end
3136
+ function Base. getindex (x:: AbstractArray , i1:: BasicSymbolic{T} , idx:: BasicSymbolic{T} , idxs... ) where {T}
3137
+ getindex (Const {T} (x), i1, idx, idxs... )
3138
+ end
3124
3139
function Base. getindex (x:: AbstractArray , i1, i2, idx:: BasicSymbolic{T} , idxs... ) where {T}
3125
3140
getindex (Const {T} (x), i1, i2, idx, idxs... )
3126
3141
end
3142
+ function Base. getindex (x:: AbstractArray , i1, i2:: BasicSymbolic{T} , idx:: BasicSymbolic{T} , idxs... ) where {T}
3143
+ getindex (Const {T} (x), i1, i2, idx, idxs... )
3144
+ end
3145
+ function Base. getindex (x:: AbstractArray , i1:: BasicSymbolic{T} , i2:: BasicSymbolic{T} , idx:: BasicSymbolic{T} , idxs... ) where {T}
3146
+ getindex (Const {T} (x), i1, i2, idx, idxs... )
3147
+ end
0 commit comments