diff --git a/base/deprecated.jl b/base/deprecated.jl index 3524b4f1f28a6..c0bb199f0fe09 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -1298,6 +1298,18 @@ end end end +# #19635 +for fname in (:ones, :zeros) + @eval @deprecate ($fname)(T::Type, arr) ($fname)(T, size(arr)) + @eval ($fname)(T::Type, i::Integer) = ($fname)(T, (i,)) + @eval function ($fname){T}(::Type{T}, arr::Array{T}) + msg = string("`", $fname, "{T}(::Type{T}, arr::Array{T})` is deprecated, use ", + "`", $fname , "(T, size(arr))` instead. ", + ) + error(msg) + end +end + # END 0.6 deprecations # BEGIN 1.0 deprecations diff --git a/test/arrayops.jl b/test/arrayops.jl index 0c849a5368f62..86812bbe34708 100644 --- a/test/arrayops.jl +++ b/test/arrayops.jl @@ -2054,12 +2054,11 @@ end zs = zeros(SparseMatrixCSC([1 2; 3 4]), Complex{Float64}, (2,3)) test_zeros(zs, SparseMatrixCSC{Complex{Float64}}, (2, 3)) - @testset "#19265" begin - @test_throws MethodError zeros(Float64, [1.]) - x = [1.] - test_zeros(zeros(x, Float64), Vector{Float64}, (1,)) - @test x == [1.] - end + # #19265" + @test_throws ErrorException zeros(Float64, [1.]) # TODO change to MethodError, when v0.6 deprecations are done + x = [1.] + test_zeros(zeros(x, Float64), Vector{Float64}, (1,)) + @test x == [1.] # exotic indexing oarr = zeros(randn(3), UInt16, 1:3, -1:0)