From a2d824473f9e2580081c363337e0425051096050 Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Sun, 5 Feb 2017 22:54:10 -0800 Subject: [PATCH] Remove multidimensional indexing of tuples 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. --- base/multidimensional.jl | 1 - test/tuple.jl | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/base/multidimensional.jl b/base/multidimensional.jl index b7b305dd621db..b9ed64d18e18d 100644 --- a/base/multidimensional.jl +++ b/base/multidimensional.jl @@ -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 diff --git a/test/tuple.jl b/test/tuple.jl index 4470ac6992257..acf40f4306fd5 100644 --- a/test/tuple.jl +++ b/test/tuple.jl @@ -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