Skip to content

Commit

Permalink
invoke more abstract print in non-compact case
Browse files Browse the repository at this point in the history
@simonschoelly identified this problem in
#282 (comment)
where calling show would lead to a stackoverflow error due to infinite
recursion. The solution is to explicitly invoke Base's abstract show
function when the non-compact form is requested to prevent the runaway
recursion.
  • Loading branch information
tlnagy committed Sep 7, 2018
1 parent 909f22f commit b731974
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/container.jl
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ function show(io::IO, ctx::Context)
end
print(io, ")")
else
print(io, ctx)
invoke(show, Tuple{IO, Any}, io, ctx)
end
end

Expand All @@ -592,6 +592,6 @@ function showcompact_array(io::IO, a::AbstractArray)
print(io, "]")
end
showcompact_array(io::IO, a::AbstractRange) = show(io, a)
show(io::IO, f::Compose.Form) = get(io, :compact, false) ? print(io, Compose.form_string(f)) : print(io, f)
show(io::IO, p::Compose.Property) = get(io, :compact, false) ? print(io, Compose.prop_string(p)) : print(io, p)
show(io::IO, cp::ContainerPromise) = get(io, :compact, false) ? print(io, typeof(cp).name.name) : print(io, cp)
show(io::IO, f::Compose.Form) = get(io, :compact, false) ? print(io, Compose.form_string(f)) : invoke(show, Tuple{IO, Any}, io, f)
show(io::IO, p::Compose.Property) = get(io, :compact, false) ? print(io, Compose.prop_string(p)) : invoke(show, Tuple{IO, Any}, io, p)
show(io::IO, cp::ContainerPromise) = get(io, :compact, false) ? print(io, typeof(cp).name.name) : invoke(show, Tuple{IO, Any}, io, cp)

0 comments on commit b731974

Please sign in to comment.