Skip to content

Commit 233a7b9

Browse files
authored
Avoid returning the value of toplevel in Base.showarg (#173)
Fixes the `stdout` display when `toplevel` is `false`
1 parent 9589e4d commit 233a7b9

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/OffsetArrays.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,9 @@ function Base.showarg(io::IO, a::OffsetArray, toplevel)
360360
Base.showarg(io, parent(a), false)
361361
Base.showindices(io, axes(a)...)
362362
print(io, ')')
363-
toplevel && print(io, " with eltype ", eltype(a))
363+
if toplevel
364+
print(io, " with eltype ", eltype(a))
365+
end
364366
end
365367

366368
function Base.replace_in_print_matrix(A::OffsetArray{<:Any,2}, i::Integer, j::Integer, s::AbstractString)

test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,12 @@ end
929929
v = rand(3)
930930
ov = OffsetArray(v, (-2,))
931931
@test Base.replace_in_print_matrix(ov, -1, 1, " ") == Base.replace_in_print_matrix(v, 1, 1, " ")
932+
933+
# Avoid returning the value of toplevel if it is false
934+
# showarg should only print values, it shouldn't return anything
935+
@test Base.showarg(io, a, false) === nothing
936+
# check the other case too for good measure
937+
@test Base.showarg(io, a, true) === nothing
932938
end
933939

934940
@testset "readdlm/writedlm" begin

0 commit comments

Comments
 (0)