You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The struct "a" inherit from the abstract type "Function" and contains a "Dict"
b =a(Dict{Any, Any}(1=>1, 2=>2, 3=>3))
#output:# (::a) (generic function with 0 methods)
b.x[2] = b
#output:# (::a) (generic function with 0 methods)
The struct gets instantiated and an element of the field "x" is assigned with the instance itself
repr(b)
#output:# ERROR: StackOverflowError:# Stacktrace:# [1] _show_default(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Any) at .\show.jl:396# [2] show_default at .\show.jl:389 [inlined]# [3] show_function(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Function, ::Bool) at .\show.jl:445# [4] print(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Function) at .\show.jl:461# [5] print_to_string(::Function) at .\strings\io.jl:135# [6] string at .\strings\io.jl:174 [inlined]# [7] Symbol at .\strings\basic.jl:227 [inlined]# [8] isdelimited(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::Function) at .\show.jl:664# [9] show(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::Pair{Any,Any}) at .\show.jl:682# [10] show(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::Dict{Any,Any}) at .\dict.jl:38# [11] _show_default(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Any) at .\show.jl:406# ... (the last 10 lines are repeated 5022 more times)# [50232] show_default at .\show.jl:389 [inlined]# [50233] show_function(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Function, ::Bool) at .\show.jl:445# [50234] show(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Function) at .\show.jl:460# [50235] sprint(::Function, ::Function; context::Nothing, sizehint::Int64) at .\strings\io.jl:105# [50236] #repr#356 at .\strings\io.jl:227 [inlined]# [50237] repr(::Function) at .\strings\io.jl:227
When calling the "repr" function on the object it gives a StackOverflowError, but it is not normal since the function can handle circular references.
I don't think I'm the one that made the mistake because executing the same code but with"a" not being a subtype of "Function" goes as expected:
struct a
x::Dictend
b =a(Dict{Any, Any}(1=>1, 2=>2, 3=>3))
#output:# (::a) (generic function with 0 methods)
b.x[2] = b
#output:# (::a) (generic function with 0 methods)repr(b)
#output:# "a(Dict{Any,Any}(2 => a(#= circular reference @-2 =#),3 => 3,1 => 1))"#=Julia Version 1.5.1Commit 697e782ab8 (2020-08-25 20:08 UTC)Platform Info: OS: Windows (x86_64-w64-mingw32) CPU: AMD Ryzen 5 3600 6-Core Processor WORD_SIZE: 64 LIBM: libopenlibm LLVM: libLLVM-9.0.1 (ORCJIT, znver2)=#
The text was updated successfully, but these errors were encountered:
The struct "a" inherit from the abstract type "Function" and contains a "Dict"
The struct gets instantiated and an element of the field "x" is assigned with the instance itself
When calling the "repr" function on the object it gives a StackOverflowError, but it is not normal since the function can handle circular references.
I don't think I'm the one that made the mistake because executing the same code but with"a" not being a subtype of "Function" goes as expected:
The text was updated successfully, but these errors were encountered: