Skip to content

Commit

Permalink
Fix display of pairs(::Vector) (JuliaLang#26482)
Browse files Browse the repository at this point in the history
  • Loading branch information
ararslan committed Mar 16, 2018
1 parent b16acdf commit 30318cf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 4 additions & 2 deletions base/multidimensional.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1886,8 +1886,10 @@ end
end

# Show for pairs() with Cartesian indicies. Needs to be here rather than show.jl for bootstrap order
function Base.showarg(io::IO, r::Union{Iterators.Pairs{<:Integer, <:Any, <:Any, T} where T <: Union{AbstractVector, Tuple},
Iterators.Pairs{<:CartesianIndex, <:Any, <:Any, T} where T <: AbstractArray}, toplevel)
function Base.showarg(io::IO, r::Iterators.Pairs{<:Integer, <:Any, <:Any, T}, toplevel) where T <: Union{AbstractVector, Tuple}
print(io, "pairs(::$T)")
end
function Base.showarg(io::IO, r::Iterators.Pairs{<:CartesianIndex, <:Any, <:Any, T}, toplevel) where T <: AbstractArray
print(io, "pairs(::$T)")
end

Expand Down
7 changes: 7 additions & 0 deletions test/iterators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,13 @@ end
@test valtype(d) == V
@test eltype(d) == Pair{K, V}
end

let io = IOBuffer()
Base.showarg(io, pairs([1,2,3]), true)
@test String(take!(io)) == "pairs(::Array{$Int,1})"
Base.showarg(io, pairs((a=1, b=2)), true)
@test String(take!(io)) == "pairs(::NamedTuple)"
end
end

@testset "reverse iterators" begin
Expand Down

0 comments on commit 30318cf

Please sign in to comment.