diff --git a/base/deprecated.jl b/base/deprecated.jl index 9f95b3af25763..8fc867d264439 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -1304,10 +1304,11 @@ for f in (:ones, :zeros) @eval ($f)(T::Type, i::Integer) = ($f)(T, (i,)) @eval function ($f){T}(::Type{T}, arr::Array{T}) msg = string("`", $f , "{T}(::Type{T}, arr::Array{T})` is deprecated, use ", - "`", $f , "(T, size(arr))` instead.", + "`", $f , "(T, size(arr))` instead. ", "A `MethodError` will be thrown." ) - error(msg) + Base.depwarn(msg, Symbol($f)) + throw(MethodError($f, (T, arr))) end end diff --git a/test/arrayops.jl b/test/arrayops.jl index 025d78d77958a..3ee7f3cd56c56 100644 --- a/test/arrayops.jl +++ b/test/arrayops.jl @@ -2055,7 +2055,7 @@ end test_zeros(zs, SparseMatrixCSC{Complex{Float64}}, (2, 3)) # #19265" - @test_throws Exception zeros(Float64, [1.]) + @test_throws MethodError zeros(Float64, [1.]) x = [1.] test_zeros(zeros(x, Float64), Vector{Float64}, (1,)) @test x == [1.]