diff --git a/src/OffsetArrays.jl b/src/OffsetArrays.jl index ef928014..f6feb109 100644 --- a/src/OffsetArrays.jl +++ b/src/OffsetArrays.jl @@ -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) diff --git a/test/runtests.jl b/test/runtests.jl index f563bca1..8e5dac30 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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