From 1feb5059f81456ea5916aa0225d22f2bc6a5479a Mon Sep 17 00:00:00 2001 From: Matt Bauman Date: Mon, 7 May 2018 16:45:56 -0500 Subject: [PATCH] Move scalar broadcast setindex_shape_check method to deprecated (#26967) * Remove unnecessary setindex_shape_check method * Ensure deprecation still works and fixup tests --- base/deprecated.jl | 1 + base/indices.jl | 1 - test/arrayops.jl | 4 ++-- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/base/deprecated.jl b/base/deprecated.jl index 8fdc538b55cd4..b4af4c91dd347 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -1496,6 +1496,7 @@ end # PR #26347: Deprecate implicit scalar broadcasting in setindex! _axes(::Ref) = () _axes(x) = axes(x) +setindex_shape_check(X::Base.Iterators.Repeated, I...) = nothing function deprecate_scalar_setindex_broadcast_message(v, I...) value = (_axes(Base.Broadcast.broadcastable(v)) == () ? "x" : "(x,)") "using `A[I...] = x` to implicitly broadcast `x` across many locations is deprecated. Use `A[I...] .= $value` instead." diff --git a/base/indices.jl b/base/indices.jl index e05d489380a6d..985b4cc9245c9 100644 --- a/base/indices.jl +++ b/base/indices.jl @@ -155,7 +155,6 @@ function setindex_shape_check(X::AbstractArray{<:Any,2}, i::Integer, j::Integer) throw_setindex_mismatch(X, (i,j)) end end -setindex_shape_check(X, I...) = nothing # Non-arrays broadcast to all idxs # convert to a supported index type (array or Int) """ diff --git a/test/arrayops.jl b/test/arrayops.jl index 3ed217d0dfcb9..996bbc0702e17 100644 --- a/test/arrayops.jl +++ b/test/arrayops.jl @@ -337,8 +337,8 @@ end @test findall(in([1, 2]), 2) == [1] @test findall(in([1, 2]), 3) == [] - rt = Base.return_types(setindex!, Tuple{Array{Int32, 3}, UInt8, Vector{Int}, Int16, UnitRange{Int}}) - @test length(rt) == 1 && rt[1] == Array{Int32, 3} + rt = Base.return_types(setindex!, Tuple{Array{Int32, 3}, Vector{UInt8}, Vector{Int}, Int16, UnitRange{Int}}) + @test length(rt) == 1 && rt[1] === Array{Int32, 3} end @testset "construction" begin @test typeof(Vector{Int}(undef, 3)) == Vector{Int}