Skip to content

Commit

Permalink
Fix showindices for IdentityUnitRange (#40608)
Browse files Browse the repository at this point in the history
(cherry picked from commit e9ef280)
  • Loading branch information
jishnub authored and KristofferC committed May 12, 2021
1 parent eac11b9 commit 1ce1103
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2721,7 +2721,7 @@ function showarg(io::IO, v::SubArray, toplevel)
print(io, ')')
toplevel && print(io, " with eltype ", eltype(v))
end
showindices(io, ::Union{Slice,IdentityUnitRange}, inds...) =
showindices(io, ::Slice, inds...) =
(print(io, ", :"); showindices(io, inds...))
showindices(io, ind1, inds...) =
(print(io, ", ", ind1); showindices(io, inds...))
Expand Down
6 changes: 6 additions & 0 deletions test/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1587,6 +1587,12 @@ end
@test summary(p) == "2×4 PermutedDimsArray(reshape(view(::Array{Int16, 3}, :, 3, 2:5), 4, 2), (2, 1)) with eltype Int16"
p = reinterpret(reshape, Tuple{Float32,Float32}, [1.0f0 3.0f0; 2.0f0 4.0f0])
@test summary(p) == "2-element reinterpret(reshape, Tuple{Float32, Float32}, ::Matrix{Float32}) with eltype Tuple{Float32, Float32}"

io = IOBuffer()
r = Base.IdentityUnitRange(2:2)
B = @view ones(2)[r]
Base.showarg(io, B, false)
@test String(take!(io)) == "view(::Vector{Float64}, $(repr(r)))"
end

@testset "Methods" begin
Expand Down

0 comments on commit 1ce1103

Please sign in to comment.