Skip to content

Commit

Permalink
Remove multidimensional indexing of tuples
Browse files Browse the repository at this point in the history
Previously a method for tuples existed which permited multidimensional
indexing. However, the method merely splatted the dimensions and ended
up calling itself, infinitely recursing. This commit removes the method
entirely and adds tests to ensure the behavior doesn't return.
  • Loading branch information
ararslan committed Feb 6, 2017
1 parent 1e085b9 commit a2d8244
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 0 additions & 1 deletion base/multidimensional.jl
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,6 @@ uncolon(inds::Tuple, I::Tuple{Colon, Vararg{CI0}}) = Slice(OneTo(trailingsi

### From abstractarray.jl: Internal multidimensional indexing definitions ###
getindex(x::Number, i::CartesianIndex{0}) = x
getindex(t::Tuple, I...) = getindex(t, IteratorsMD.flatten(I)...)

# These are not defined on directly on getindex to avoid
# ambiguities for AbstractArray subtypes. See the note in abstractarray.jl
Expand Down
5 changes: 5 additions & 0 deletions test/tuple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,8 @@ end
@test Tuple{Int,Vararg{Any}}(Float64[1,2,3]) === (1, 2.0, 3.0)
@test Tuple(ones(5)) === (1.0,1.0,1.0,1.0,1.0)
@test_throws MethodError convert(Tuple, ones(5))

@testset "Multidimensional indexing (issue #20453)" begin
@test_throws MethodError (1,)[]
@test_throws MethodError (1,1,1)[1,1]
end

0 comments on commit a2d8244

Please sign in to comment.