Weird errors in Juno

I’m using the current version of Juno (uber-juno 0.3.0) on Atom 1.42.0, with Julia 1.3.0 (Julia 1.3.1 has the same issues, just slightly different error messages). I’ve been seeing weird errors that only happen in Juno, not in Julia command line (from the terminal, outside of Juno).

Consider the following code:

mutable struct AS
    a
    b
    AS() = new(1.0)
end
function set_states!(c::AS, b::Number)
    c.b = b
end

AAS = [AS() for _ in 1:5]

Running it in Juno is fine, returning:

2-element Array{AS,1}:
 AS(1.0, #undef)
 AS(1.0, #undef)

Then run the following code:

for k in 1:2
    set_states!(AAS[k], 0.)
end

It will basically crash Julia in Juno with the error (text is long, so I only include the first few lines):

Error showing value of type Array{AS,1}:
ERROR: StackOverflowError:
Stacktrace:
 [1] _show_default(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::Any) at ./show.jl:334
 [2] show_default at ./show.jl:330 [inlined]
 [3] show(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::Any) at ./show.jl:327
 ... (the last 3 lines are repeated 26170 more times)

What could be wrong?

A different but still weird error for similar code (just changed slightly from the above).

Run the following code in Juno (paste in a file, select, then run the code):

mutable struct AS
    a
    b
    AS() = new(1.0, 2.0)
end
function set_states!(c::AS, b::Number)
    c.b = b
end

AAS = [AS() for _ in 1:2]

As you can see, it’s changed only slightly from the previous. It returns as expected

2-element Array{AS,1}:
 AS(1.0, 2.0)
 AS(1.0, 2.0)

Then run the following code in Juno (paste, select, run):

for k in 1:2
    set_states!(AAS[k], 0.)
end

Then type AAS[1] in the REPL in Juno and get:

AS(1.0, (Core.Compiler.UseRef(:(Core.bitcast(Core.UInt, %96)), 4), nothing))

It should have shown AS(1.0, 0.0) instead.

I don’t know exactly why but the error does not happen if you set the type of the struct members:

mutable struct AS
    a::Float64
    b::Float64
    AS() = new(1.0, 2.0)
end
julia> begin
       mutable struct AS
           a
           b
           AS() = new(1.0)
       end
       function set_states!(c::AS, b::Number)
           c.b = b
       end

       AAS = [AS() for _ in 1:2]
       end;

julia> for k in 1:2
           @show AAS[k]
           @show set_states!(AAS[k], 9.91)
           @show AAS[k]
       end
AAS[k] = AS(1.0, #undef)
set_states!(AAS[k], 9.91) = 9.91
AAS[k] = AS(1.0, 9.91)
AAS[k] = AS(1.0, #undef)
set_states!(AAS[k], 9.91) = 9.91
AAS[k] = AS(1.0, 9.91)

julia> @show AAS[1];
AAS[1] = AS(1.0, 9.91)

julia> AAS
2-element Array{AS,1}:
 AS(1.0, :(%1090))
 AS(1.0, :(%1090))

julia> AAS
2-element Array{AS,1}:
Error showing value of type Array{AS,1}:

I suspect this happens because Juno is holding on to AAS in a bunch of nested closures and then something bad happens and we’re back to the original, unset value interpreted as a pointer to random memory or whatever.
No idea why this is happening though, I’m fairly certain Juno never does any modifications to displayed objects like that.