Closed vustef closed 1 year ago
Here's a repro:
using JSON abstract type AbstractBar end mutable struct Foo4 bar::Union{Nothing, AbstractBar} end struct Bar4 <: AbstractBar foo::Ref{Foo4} end foo4 = Foo4(nothing) bar4 = Bar4(foo4) foo4.bar = bar4 dict = Dict{String, Any}() dict["FOO"] = foo4 # Prints forever. # JSON.print(stdout, dict)
On the other hand, if I just use @show, it prevents infinite recursion:
@show
julia> @show dict dict = Dict{String, Any}("FOO" => Foo4(Bar4(Base.RefValue{Foo4}(Foo4(#= circular reference @-3 =#))))) Dict{String, Any} with 1 entry: "FOO" => Foo4(Bar4(RefValue{Foo4}(Foo4(#= circular reference @-3 =#))))
Actually, this might have already been fixed with the latest commit: https://github.com/JuliaIO/JSON.jl/commit/2219019b6dfb19c7dcc13754ab65d86225d01146. I'll reopen if not.
Here's a repro:
On the other hand, if I just use
@show
, it prevents infinite recursion: