Skip to content

Commit 0900553

Browse files
authored
Merge pull request #20468 from JuliaLang/aa/tuple-indexing
Remove multidimensional indexing of tuples
2 parents a6600d1 + 9212ca6 commit 0900553

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

base/multidimensional.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ uncolon(inds::Tuple, I::Tuple{Colon, Vararg{CI0}}) = Slice(OneTo(trailingsi
384384

385385
### From abstractarray.jl: Internal multidimensional indexing definitions ###
386386
getindex(x::Number, i::CartesianIndex{0}) = x
387-
getindex(t::Tuple, I...) = getindex(t, IteratorsMD.flatten(I)...)
387+
getindex(t::Tuple, i::CartesianIndex{1}) = getindex(t, i.I[1])
388388

389389
# These are not defined on directly on getindex to avoid
390390
# ambiguities for AbstractArray subtypes. See the note in abstractarray.jl

test/tuple.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,3 +231,8 @@ end
231231
@test Tuple{Int,Vararg{Any}}(Float64[1,2,3]) === (1, 2.0, 3.0)
232232
@test Tuple(ones(5)) === (1.0,1.0,1.0,1.0,1.0)
233233
@test_throws MethodError convert(Tuple, ones(5))
234+
235+
@testset "Multidimensional indexing (issue #20453)" begin
236+
@test_throws MethodError (1,)[]
237+
@test_throws MethodError (1,1,1)[1,1]
238+
end

0 commit comments

Comments
 (0)