diff --git a/base/reshapedarray.jl b/base/reshapedarray.jl index 3ac1c7cac616f..902200eb0d3d3 100644 --- a/base/reshapedarray.jl +++ b/base/reshapedarray.jl @@ -168,6 +168,11 @@ function __reshape(p::Tuple{AbstractArray,IndexCartesian}, dims::Dims) ReshapedArray(parent, dims, reverse(mi)) end +function __reshape(p::Tuple{AbstractArray{<:Any,0},IndexCartesian}, dims::Dims) + parent = p[1] + ReshapedArray(parent, dims, ()) +end + function __reshape(p::Tuple{AbstractArray,IndexLinear}, dims::Dims) parent = p[1] ReshapedArray(parent, dims, ()) diff --git a/test/arrayops.jl b/test/arrayops.jl index 22a99aa711bbb..788aa899510ec 100644 --- a/test/arrayops.jl +++ b/test/arrayops.jl @@ -189,6 +189,22 @@ end end end +struct Z26163 <: AbstractArray{Int,0}; end +Base.size(::Z26163) = () +Base.getindex(::Z26163) = 0 +struct V26163 <: AbstractArray{Int,1}; end +Base.size(::V26163) = (1,) +Base.getindex(::V26163, ::Int) = 0 +@testset "reshape of custom zero- and one-dimensional arrays" begin + z = Z26163() + v = V26163() + @test z == reshape(v, ()) == fill(0, ()) + @test reshape(z, 1) == v == [0] + @test reshape(z, 1, 1) == reshape(v, 1, 1) == fill(0, 1, 1) + @test occursin("1-element reshape", summary(reshape(z, 1))) + @test_broken occursin("0-dimensional reshape", summary(reshape(v, ()))) +end + @test reshape(1:5, (5,)) === 1:5 @test reshape(1:5, 5) === 1:5 diff --git a/test/strings/io.jl b/test/strings/io.jl index cb928f65f001c..9ba490b5f3310 100644 --- a/test/strings/io.jl +++ b/test/strings/io.jl @@ -144,7 +144,8 @@ end end @testset "join()" begin - @test join([]) == "" + @test join([]) == join([],",") == "" + @test_broken join(()) == join((),",") == "" @test join(["a"],"?") == "a" @test join("HELLO",'-') == "H-E-L-L-O" @test join(1:5, ", ", " and ") == "1, 2, 3, 4 and 5"