diff --git a/base/abstractarray.jl b/base/abstractarray.jl index fbecc43efa4f8..408f05f4645ef 100644 --- a/base/abstractarray.jl +++ b/base/abstractarray.jl @@ -1656,12 +1656,13 @@ function mapslices(f, A::AbstractArray, dims::AbstractVector) end # These are needed because map(eltype, As) is not inferrable -promote_eltype_op(::Any) = (@_pure_meta; Bottom) +promote_eltype_op(::Any) = (@_pure_meta; Any) promote_eltype_op(op, A) = (@_pure_meta; promote_op(op, eltype(A))) promote_eltype_op{T}(op, ::AbstractArray{T}) = (@_pure_meta; promote_op(op, T)) promote_eltype_op{T}(op, ::AbstractArray{T}, A) = (@_pure_meta; promote_op(op, T, eltype(A))) promote_eltype_op{T}(op, A, ::AbstractArray{T}) = (@_pure_meta; promote_op(op, eltype(A), T)) promote_eltype_op{R,S}(op, ::AbstractArray{R}, ::AbstractArray{S}) = (@_pure_meta; promote_op(op, R, S)) +promote_eltype_op(op, A, B) = (@_pure_meta; promote_op(op, eltype(A), eltype(B))) promote_eltype_op(op, A, B, C, D...) = (@_pure_meta; promote_eltype_op(op, promote_eltype_op(op, A, B), C, D...)) ## 1 argument diff --git a/base/broadcast.jl b/base/broadcast.jl index e42f2a67edfbc..aee5920bb9386 100644 --- a/base/broadcast.jl +++ b/base/broadcast.jl @@ -213,7 +213,7 @@ function broadcast_t(f, ::Type{Any}, As...) shape = broadcast_shape(As...) iter = CartesianRange(shape) if isempty(iter) - return similar(Array{Union{}}, shape) + return similar(Array{Any}, shape) end nargs = length(As) keeps, Idefaults = map_newindexer(shape, As) diff --git a/test/abstractarray.jl b/test/abstractarray.jl index 807e5da5a7398..f8f3e158b8cf8 100644 --- a/test/abstractarray.jl +++ b/test/abstractarray.jl @@ -746,3 +746,12 @@ end @test ndims(Diagonal(rand(1:5,5))) == 2 @test ndims(Diagonal{Float64}) == 2 @test Base.elsize(Diagonal(rand(1:5,5))) == sizeof(Int) + +# Issue #17811 +let A17811 = Integer[] + I = [abs(x) for x in A17811] + @test isa(I, Array{Any,1}) + push!(I, 1) + @test I == Any[1] + @test isa(map(abs, A17811), Array{Any,1}) +end diff --git a/test/broadcast.jl b/test/broadcast.jl index ec4d4ebf111ef..bbc2afb6d560c 100644 --- a/test/broadcast.jl +++ b/test/broadcast.jl @@ -311,9 +311,19 @@ end let f17314 = x -> x < 0 ? false : x @test eltype(broadcast(f17314, 1:3)) === Int @test eltype(broadcast(f17314, -1:1)) === Integer - @test eltype(broadcast(f17314, Int[])) === Union{} + @test eltype(broadcast(f17314, Int[])) === Any end let io = IOBuffer() broadcast(x->print(io,x), 1:5) # broadcast with side effects @test takebuf_array(io) == [0x31,0x32,0x33,0x34,0x35] end + +# Issue 18176 +let f18176(a, b, c) = a + b + c + @test f18176.(1.0:2, 3, 4) == f18176.(3.0, 1.0:2, 4.0) == broadcast(f18176, 3, 4, 1.0:2) +end + +# Issue #17984 +let A17984 = [] + @test isa(abs.(A17984), Array{Any,1}) +end diff --git a/test/inference.jl b/test/inference.jl index 6d61d6d657a4a..8a2e883a77d66 100644 --- a/test/inference.jl +++ b/test/inference.jl @@ -275,14 +275,6 @@ let f(x) = (x===nothing) ? 1 : 1.0 @test Base.return_types(f, (Void,)) == Any[Int] end -# Issue #17811 -let I = Integer[] - I = abs(I) - @test typeof(I) == Array{Any,1} - push!(I, 1) - @test I == Any[1] -end - # issue #16530 type Foo16530a{dim} c::Vector{NTuple{dim, Float64}}