Closed mfiano closed 1 year ago
julia> module Ex using SumTypes struct Foo end @sum_type FooWrapper{T} begin FooWrapper1{T}(::T) FooWrapper2{T}(::T) FooWrapper3{T}(::T) end function SumTypes.show_sumtype(io::IO, x::FooWrapper{Foo}) foo = SumTypes.unwrap(x).data[1] print(io, x) end end Main.Ex julia> Ex.FooWrapper2(Ex.Foo()) Error showing value of type Main.Ex.FooWrapper{Main.Ex.Foo, 0, 0, UInt8}: ERROR: StackOverflowError: caused by: StackOverflowError: Stacktrace: [1] print(io::IOContext{Base.TTY}, x::Main.Ex.FooWrapper{Main.Ex.Foo, 0, 0, UInt8}) @ Base ./strings/io.jl:37 [2] show_sumtype(io::IOContext{Base.TTY}, x::Main.Ex.FooWrapper{Main.Ex.Foo, 0, 0, UInt8}) @ Main.Ex ./REPL[4]:15 [3] show(io::IOContext{Base.TTY}, x::Main.Ex.FooWrapper{Main.Ex.Foo, 0, 0, UInt8}) @ Main.Ex ~/.data/julia/packages/SumTypes/Hn80O/src/sum_type.jl:293 [4] print(io::IOContext{Base.TTY}, x::Main.Ex.FooWrapper{Main.Ex.Foo, 0, 0, UInt8}) @ Base ./strings/io.jl:35 --- the last 3 lines are repeated 9277 more times --- [27836] show_sumtype(io::IOContext{Base.TTY}, x::Main.Ex.FooWrapper{Main.Ex.Foo, 0, 0, UInt8}) @ Main.Ex ./REPL[4]:15 [27837] show_sumtype(io::IOContext{Base.TTY}, m::MIME{Symbol("text/plain")}, x::Main.Ex.FooWrapper{Main.Ex.Foo, 0, 0, UInt8}) @ SumTypes ~/.data/julia/packages/SumTypes/Hn80O/src/SumTypes.jl:61 [27838] show(io::IOContext{Base.TTY}, m::MIME{Symbol("text/plain")}, x::Main.Ex.FooWrapper{Main.Ex.Foo, 0, 0, UInt8}) @ Main.Ex ~/.data/julia/packages/SumTypes/Hn80O/src/sum_type.jl:294 [27839] display(d::REPL.REPLDisplay, x::Any) @ REPL /usr/share/julia/stdlib/v1.9/REPL/src/REPL.jl:281 caused by: StackOverflowError: Stacktrace: [1] print(io::IOContext{Base.TTY}, x::Main.Ex.FooWrapper{Main.Ex.Foo, 0, 0, UInt8}) @ Base ./strings/io.jl:37 [2] show_sumtype(io::IOContext{Base.TTY}, x::Main.Ex.FooWrapper{Main.Ex.Foo, 0, 0, UInt8}) @ Main.Ex ./REPL[4]:15 [3] show(io::IOContext{Base.TTY}, x::Main.Ex.FooWrapper{Main.Ex.Foo, 0, 0, UInt8}) @ Main.Ex ~/.data/julia/packages/SumTypes/Hn80O/src/sum_type.jl:293 [4] print(io::IOContext{Base.TTY}, x::Main.Ex.FooWrapper{Main.Ex.Foo, 0, 0, UInt8}) @ Base ./strings/io.jl:35 --- the last 3 lines are repeated 9278 more times --- [27839] show_sumtype(io::IOContext{Base.TTY}, x::Main.Ex.FooWrapper{Main.Ex.Foo, 0, 0, UInt8}) @ Main.Ex ./REPL[4]:15 [27840] show_sumtype(io::IOContext{Base.TTY}, m::MIME{Symbol("text/plain")}, x::Main.Ex.FooWrapper{Main.Ex.Foo, 0, 0, UInt8}) @ SumTypes ~/.data/julia/packages/SumTypes/Hn80O/src/SumTypes.jl:61 [27841] show(io::IOContext{Base.TTY}, m::MIME{Symbol("text/plain")}, x::Main.Ex.FooWrapper{Main.Ex.Foo, 0, 0, UInt8}) @ Main.Ex ~/.data/julia/packages/SumTypes/Hn80O/src/sum_type.jl:294 [27842] display(d::REPL.REPLDisplay, x::Any) @ REPL /usr/share/julia/stdlib/v1.9/REPL/src/REPL.jl:281 caused by: StackOverflowError: Stacktrace: [1] print(io::IOContext{Base.TTY}, x::Main.Ex.FooWrapper{Main.Ex.Foo, 0, 0, UInt8}) @ Base ./strings/io.jl:32 [2] show_sumtype(io::IOContext{Base.TTY}, x::Main.Ex.FooWrapper{Main.Ex.Foo, 0, 0, UInt8}) @ Main.Ex ./REPL[4]:15 [3] show(io::IOContext{Base.TTY}, x::Main.Ex.FooWrapper{Main.Ex.Foo, 0, 0, UInt8}) @ Main.Ex ~/.data/julia/packages/SumTypes/Hn80O/src/sum_type.jl:293 [4] print(io::IOContext{Base.TTY}, x::Main.Ex.FooWrapper{Main.Ex.Foo, 0, 0, UInt8}) @ Base ./strings/io.jl:35 --- the last 3 lines are repeated 9279 more times --- [27842] show_sumtype(io::IOContext{Base.TTY}, x::Main.Ex.FooWrapper{Main.Ex.Foo, 0, 0, UInt8}) @ Main.Ex ./REPL[4]:15 [27843] show_sumtype(io::IOContext{Base.TTY}, m::MIME{Symbol("text/plain")}, x::Main.Ex.FooWrapper{Main.Ex.Foo, 0, 0, UInt8}) @ SumTypes ~/.data/julia/packages/SumTypes/Hn80O/src/SumTypes.jl:61 [27844] show(io::IOContext{Base.TTY}, m::MIME{Symbol("text/plain")}, x::Main.Ex.FooWrapper{Main.Ex.Foo, 0, 0, UInt8}) @ Main.Ex ~/.data/julia/packages/SumTypes/Hn80O/src/sum_type.jl:294 [27845] display(d::REPL.REPLDisplay, x::Any) @ REPL /usr/share/julia/stdlib/v1.9/REPL/src/REPL.jl:281
Please ignore. Code was not consistent with my REPL.