How to debug "type Nothing has no field color"

I hit the following bug: Switch on the tutorial project · Issue #8 · bradcarman/ModelingToolkitDesigner.jl · GitHub

But the author of the package cannot reproduce it. How can we find the reason for this bug?

Can anybody else reproduce it?

The stack trace of albheim in that issue say that the problem is on line 578 in src/ModelingToolkitDesigner.jl on version v1.0.0: https://github.com/bradcarman/ModelingToolkitDesigner.jl/blob/f56140e8b4c46583f71ab8d694bff64376cddde5/src/ModelingToolkitDesigner.jl#L569-L579

Looks like there is a isnothing check missing:

if !isnothing(selected_component)
    selected_component.color[] = :pink
else
    all_connectors =
        vcat([s.connectors for s in design.components]...)
    selected_connector = filtersingle(
        c -> is_tuple_approx(c.xy[], (x, y); atol = 1e-3),
        all_connectors,
    )
    selected_connector.color[] = :pink # line nr. 578
end
1 Like

Thanks a lot! :grinning:

1 Like