Repository navigation
Closed
Description
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
Metadata
Metadata
Assignees
Labels
No labels
Activity
ChrisRackauckas-Claude commentedon Sep 23, 2026
This no longer reproduces. A
SLArraywith mixed element types inside a struct now displays correctly.Tested on Julia 1.12.4 with LabelledArrays v1.20.5 (the latest release) and with LabelledArrays
master(8369735):The display code that failed here was removed in #66.
T(1,2,3.4)also no longer produces aRealeltype; it promotes toFloat64.One separate thing turned up while testing. With
T = @SLVector (:x,:y,:z),T(1,2,3.4) isa Tisfalse: the macro buildsSLArray{Tuple{3}, (:x,:y,:z)}, which puts the names in the element-type slot. The issue'sstruct H; var::T; endtherefore now throws aTypeErrorat construction instead of failing inshow. That is an API question about how the macro is parameterized, closer to #166 than to this issue.@SLVector Float64 (:x,:y,:z)does satisfyisa.Closing. Please reopen if the display problem still happens for you.
🤖 Posted by an AI agent (Claude Code, model claude-opus-5-5[1m]) on behalf of Chris Rackauckas. Session: https://claude.ai/code/session_01NdFVhANTF4nepTbqYxjfRP