LabelledArrays.jl
LabelledArrays.jl copied to clipboard
Display error if struct contains LabelledArray with mixed types
Struct does not get displayed if it contains a labelled array with mixed types.
julia> using LabelledArrays
julia> T = @SLVector (:x,:y,:z)
SLArray{Tuple{3},1,(:x, :y, :z),T} where T
julia> T(1,2,3.4)
3-element SLArray{Tuple{3},1,(:x, :y, :z),Real}:
1
2
3.4
julia> [typeof(x) for x in T(1,2,3.4)]
3-element StaticArrays.SizedArray{Tuple{3},DataType,1,1}:
Int64
Int64
Float64
julia> struct H
var :: T
end
julia> a=H(T(1,2,3.4))
H(Error showing value of type H:
ERROR: MethodError: Cannot `convert` an object of type LabelledArrays.DisplayCell{Int64} to an object of type LabelledArrays.DisplayCell{Real}
Closest candidates are:
convert(::Type{T}, ::T) where T at essentials.jl:154
LabelledArrays.DisplayCell{Real}(::Any, ::Any) where T at /home/user/.julia/packages/LabelledArrays/Y2gSe/src/display.jl:2
Stacktrace:
[1] setindex!(::Array{LabelledArrays.DisplayCell{Real},1}, ::LabelledArrays.DisplayCell{Int64}, ::Int64) at ./array.jl:767
[2] show(::IOContext{REPL.Terminals.TTYTerminal}, ::SLArray{Tuple{3},1,(:x, :y, :z),Real}) at /home/user/.julia/packages/LabelledArrays/Y2gSe/src/display.jl:22
[3] show_default(::IOContext{REPL.Terminals.TTYTerminal}, ::Any) at ./show.jl:332
[4] show at ./show.jl:315 [inlined]
[5] show(::IOContext{REPL.Terminals.TTYTerminal}, ::MIME{Symbol("text/plain")}, ::H) at ./sysimg.jl:194
[6] display(::REPL.REPLDisplay, ::MIME{Symbol("text/plain")}, ::Any) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/REPL/src/REPL.jl:131
[7] display(::REPL.REPLDisplay, ::Any) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/REPL/src/REPL.jl:135
[8] display(::Any) at ./multimedia.jl:287
[9] #invokelatest#1 at ./essentials.jl:742 [inlined]
[10] invokelatest at ./essentials.jl:741 [inlined]
[11] print_response(::IO, ::Any, ::Any, ::Bool, ::Bool, ::Any) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/REPL/src/REPL.jl:155
[12] print_response(::REPL.AbstractREPL, ::Any, ::Any, ::Bool, ::Bool) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/REPL/src/REPL.jl:140
[13] (::getfield(REPL, Symbol("#do_respond#38")){Bool,getfield(REPL, Symbol("##48#57")){REPL.LineEditREPL,REPL.REPLHistoryProvider},REPL.LineEditREPL,REPL.LineEdit.Prompt})(::Any, ::Any, ::Any) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/REPL/src/REPL.jl:714
[14] #invokelatest#1 at ./essentials.jl:742 [inlined]
[15] invokelatest at ./essentials.jl:741 [inlined]
[16] run_interface(::REPL.Terminals.TextTerminal, ::REPL.LineEdit.ModalInterface, ::REPL.LineEdit.MIState) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/REPL/src/LineEdit.jl:2273
[17] run_frontend(::REPL.LineEditREPL, ::REPL.REPLBackendRef) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/REPL/src/REPL.jl:1035
[18] run_repl(::REPL.AbstractREPL, ::Any) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/REPL/src/REPL.jl:192
[19] (::getfield(Base, Symbol("##734#736")){Bool,Bool,Bool,Bool})(::Module) at ./client.jl:362
[20] #invokelatest#1 at ./essentials.jl:742 [inlined]
[21] invokelatest at ./essentials.jl:741 [inlined]
[22] run_main_repl(::Bool, ::Bool, ::Bool, ::Bool, ::Bool) at ./client.jl:346
[23] exec_options(::Base.JLOptions) at ./client.jl:284
[24] _start() at ./client.jl:436