Skip to content

Commit ebc345f

Browse files
Fixes
1 parent 83a776c commit ebc345f

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

base/show.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -2771,7 +2771,7 @@ function type_depth_limit(str::String, n::Int; maxdepth = nothing)
27712771
return String(take!(output))
27722772
end
27732773

2774-
function print_type_bicolor(io, @nospecialize(type); color=:normal, inner_color=:light_black, use_color::Bool=true, depth::Int)
2774+
function print_type_bicolor(io, @nospecialize(type); color=:normal, inner_color=:light_black, use_color::Bool=true, depth::Int = 0)
27752775
if depth > max_type_depth(io)
27762776
else
27772777
str = sprint(show, type, context=io)

test/stacktraces.jl

+15
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,21 @@ end
270270
@show sprint(Base.show, typ, context = (:max_type_depth_limit => 6))
271271
end
272272

273+
Base.@kwdef struct F55952{A,B}
274+
num::Int = 1
275+
end
276+
277+
@testset "Depth-limited type printing performance for highly nested types" begin
278+
nest_val(na, nb, ::Val{1}) = F55952{na, nb}()
279+
nest_val(na, nb, ::Val{n}) where {n} = nest_val(F55952{na, nb}, F55952{na, nb}, Val(n-1))
280+
nest_val(na, nb, n::Int) = nest_val(na, nb, Val(n))
281+
nest_val(n) = nest_val(1, 1, n)
282+
typ = typeof(nest_val(23))
283+
# be careful with changing to a larger number
284+
# ~10 seconds before #55952 is fixed:
285+
@test 1 > @elapsed sprint(Base.show, typ, context = (:max_type_depth_limit => 2))
286+
end
287+
273288
@testset "Base.StackTraces docstrings" begin
274289
@test isempty(Docs.undocumented_names(StackTraces))
275290
end

0 commit comments

Comments
 (0)