Skip to content

Commit

Permalink
Avoid returning the value of toplevel in Base.showarg (#173)
Browse files Browse the repository at this point in the history
Fixes the `stdout` display when `toplevel` is `false`
  • Loading branch information
jishnub authored Dec 17, 2020
1 parent 9589e4d commit 233a7b9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/OffsetArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,9 @@ function Base.showarg(io::IO, a::OffsetArray, toplevel)
Base.showarg(io, parent(a), false)
Base.showindices(io, axes(a)...)
print(io, ')')
toplevel && print(io, " with eltype ", eltype(a))
if toplevel
print(io, " with eltype ", eltype(a))
end
end

function Base.replace_in_print_matrix(A::OffsetArray{<:Any,2}, i::Integer, j::Integer, s::AbstractString)
Expand Down
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,12 @@ end
v = rand(3)
ov = OffsetArray(v, (-2,))
@test Base.replace_in_print_matrix(ov, -1, 1, " ") == Base.replace_in_print_matrix(v, 1, 1, " ")

# Avoid returning the value of toplevel if it is false
# showarg should only print values, it shouldn't return anything
@test Base.showarg(io, a, false) === nothing
# check the other case too for good measure
@test Base.showarg(io, a, true) === nothing
end

@testset "readdlm/writedlm" begin
Expand Down

0 comments on commit 233a7b9

Please sign in to comment.