diff --git a/base/boot.jl b/base/boot.jl index 1ab6488471a9b..20f786d6415e5 100644 --- a/base/boot.jl +++ b/base/boot.jl @@ -322,7 +322,6 @@ typealias NTuple{N,T} Tuple{Vararg{T,N}} (::Type{Array{T}}){T}(m::Int, n::Int, o::Int) = Array{T,3}(m, n, o) (::Type{Array{T,1}}){T}() = Array{T,1}(0) -(::Type{Array{T,2}}){T}() = Array{T,2}(0, 0) # primitive Symbol constructors function Symbol(s::String) diff --git a/base/deprecated.jl b/base/deprecated.jl index c3fd283b7c115..b538e3da0b5e8 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -1213,6 +1213,17 @@ end) @deprecate FloatRange{T}(start::T, step, len, den) Base.floatrange(T, start, step, len, den) +@noinline zero_arg_matrix_constructor(prefix::String) = + depwarn("$prefix() is deprecated, use $prefix(0, 0) instead.", :zero_arg_matrix_constructor) +function (::Type{Matrix{T}}){T}() + zero_arg_matrix_constructor("Matrix{T}") + return Matrix{T}(0, 0) +end +function (::Type{Matrix})() + zero_arg_matrix_constructor("Matrix") + return Matrix(0, 0) +end + for name in ("alnum", "alpha", "cntrl", "digit", "number", "graph", "lower", "print", "punct", "space", "upper", "xdigit") f = Symbol("is",name) diff --git a/base/sysimg.jl b/base/sysimg.jl index 5a42220deb2cb..7c875a64e330f 100644 --- a/base/sysimg.jl +++ b/base/sysimg.jl @@ -96,7 +96,6 @@ include("subarray.jl") (::Type{Vector})() = Array{Any,1}(0) (::Type{Vector{T}}){T}(m::Integer) = Array{T,1}(Int(m)) (::Type{Vector})(m::Integer) = Array{Any,1}(Int(m)) -(::Type{Matrix})() = Array{Any,2}(0, 0) (::Type{Matrix{T}}){T}(m::Integer, n::Integer) = Matrix{T}(Int(m), Int(n)) (::Type{Matrix})(m::Integer, n::Integer) = Matrix{Any}(Int(m), Int(n)) diff --git a/test/arrayops.jl b/test/arrayops.jl index 2deedafaaca68..96f212198152c 100644 --- a/test/arrayops.jl +++ b/test/arrayops.jl @@ -271,18 +271,30 @@ end @test typeof(Vector(3)) == Vector{Any} @test typeof(Vector()) == Vector{Any} @test typeof(Matrix{Int}(2,3)) == Matrix{Int} - @test typeof(Matrix{Int}()) == Matrix{Int} @test typeof(Matrix(2,3)) == Matrix{Any} - @test typeof(Matrix()) == Matrix{Any} @test size(Vector{Int}(3)) == (3,) @test size(Vector{Int}()) == (0,) @test size(Vector(3)) == (3,) @test size(Vector()) == (0,) @test size(Matrix{Int}(2,3)) == (2,3) - @test size(Matrix{Int}()) == (0,0) @test size(Matrix(2,3)) == (2,3) - @test size(Matrix()) == (0,0) + + # TODO: will throw MethodError after 0.6 deprecations are deleted + dw = Base.JLOptions().depwarn + if dw == 2 + @test_throws ErrorException Matrix{Int}() + @test_throws ErrorException Matrix() + elseif dw == 1 + @test_warn "deprecated" Matrix{Int}() + @test_warn "deprecated" Matrix() + elseif dw == 0 + @test size(Matrix{Int}()) == (0,0) + @test size(Matrix()) == (0,0) + else + error("unexpected depwarn value") + end + @test_throws MethodError Array{Int,3}() end @testset "get" begin A = reshape(1:24, 3, 8)