Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error displaying an array of tuples of tuples #25857

Closed
mbauman opened this issue Feb 2, 2018 · 4 comments
Closed

Error displaying an array of tuples of tuples #25857

mbauman opened this issue Feb 2, 2018 · 4 comments
Labels
arrays [a, r, r, a, y, s] display and printing Aesthetics and correctness of printed representations of objects. regression Regression in behavior compared to a previous version

Comments

@mbauman
Copy link
Member

mbauman commented Feb 2, 2018

julia> [((), BitArray{0}), ((1,), BitVector), ((1,2), BitMatrix)]
3-element Array{Tuple{Tuple{Vararg{Int64,N} where N},DataType},1}:
Error showing value of type Array{Tuple{Tuple{Vararg{Int64,N} where N},DataType},1}:
ERROR: BoundsError: attempt to access svec(Vararg{Int64,N} where N)
  at index [2]
Stacktrace:
 [1] getindex(::SimpleVector, ::Int64) at ./essentials.jl:512
 [2] show_delim_array(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::Tuple{Int64,Int64}, ::Char, ::Char, ::Char, ::Bool, ::Int64, ::Int64) at ./show.jl:688
 [3] show_delim_array at ./show.jl:674 [inlined]
 [4] show(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::Tuple{Int64,Int64}) at ./show.jl:706
 [5] show_delim_array(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::Tuple{Tuple{Int64,Int64},DataType}, ::Char, ::Char, ::Char, ::Bool, ::Int64, ::Int64) at ./show.jl:688
 [6] show_delim_array at ./show.jl:674 [inlined]
 [7] show(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::Tuple{Tuple{Int64,Int64},DataType}) at ./show.jl:706
 [8] #sprint#343(::IOContext{REPL.Terminals.TTYTerminal}, ::Int64, ::Function, ::Function, ::Tuple{Tuple{Int64,Int64},DataType}, ::Vararg{Tuple{Tuple{Int64,Int64},DataType},N} where N) at ./strings/io.jl:89
 [9] #sprint at ./<missing>:0 [inlined]
 [10] alignment(::IOContext{REPL.Terminals.TTYTerminal}, ::Tuple{Tuple{Int64,Int64},DataType}) at ./show.jl:1842
 [11] alignment(::IOContext{REPL.Terminals.TTYTerminal}, ::Array{Tuple{Tuple{Vararg{Int64,N} where N},DataType},1}, ::Base.OneTo{Int64}, ::Base.OneTo{Int64}, ::Int64, ::Int64, ::Int64) at ./arrayshow.jl:68
 [12] print_matrix(::IOContext{REPL.Terminals.TTYTerminal}, ::Array{Tuple{Tuple{Vararg{Int64,N} where N},DataType},1}, ::String, ::String, ::String, ::String, ::String, ::String, ::Int64, ::Int64) at ./arrayshow.jl:187
 [13] print_matrix at ./arrayshow.jl:160 [inlined]
 [14] print_array at ./arrayshow.jl:309 [inlined]
 [15] _display(::IOContext{REPL.Terminals.TTYTerminal}, ::Array{Tuple{Tuple{Vararg{Int64,N} where N},DataType},1}) at ./arrayshow.jl:345
 [16] show(::IOContext{REPL.Terminals.TTYTerminal}, ::MIME{Symbol("text/plain")}, ::Array{Tuple{Tuple{Vararg{Int64,N} where N},DataType},1}) at ./arrayshow.jl:348
 [17] display(::REPL.REPLDisplay{REPL.LineEditREPL}, ::MIME{Symbol("text/plain")}, ::Array{Tuple{Tuple{Vararg{Int64,N} where N},DataType},1}) at /data/mbauman/julia-master/usr/share/julia/site/v0.7/REPL/src/REPL.jl:125
 [18] display(::REPL.REPLDisplay{REPL.LineEditREPL}, ::Array{Tuple{Tuple{Vararg{Int64,N} where N},DataType},1}) at /data/mbauman/julia-master/usr/share/julia/site/v0.7/REPL/src/REPL.jl:128
 [19] display(::Array{Tuple{Tuple{Vararg{Int64,N} where N},DataType},1}) at ./multimedia.jl:291
 [20] (::getfield(Base, Symbol("#inner#4")){Base.Iterators.IndexValue{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},typeof(display),Tuple{Array{Tuple{Tuple{Vararg{Int64,N} where N},DataType},1}}})() at ./essentials.jl:646
 [21] #invokelatest#3 at ./essentials.jl:647 [inlined]
 [22] invokelatest at ./essentials.jl:646 [inlined]
 [23] print_response(::REPL.Terminals.TTYTerminal, ::Any, ::Nothing, ::Bool, ::Bool, ::Nothing) at /data/mbauman/julia-master/usr/share/julia/site/v0.7/REPL/src/REPL.jl:146
 [24] print_response(::REPL.LineEditREPL, ::Any, ::Nothing, ::Bool, ::Bool) at /data/mbauman/julia-master/usr/share/julia/site/v0.7/REPL/src/REPL.jl:132
 [25] (::getfield(REPL, Symbol("#do_respond#15")){Bool,getfield(REPL, Symbol("##25#35")){REPL.LineEditREPL,REPL.REPLHistoryProvider},REPL.LineEditREPL,REPL.LineEdit.Prompt})(::REPL.LineEdit.MIState, ::Base.GenericIOBuffer{Array{UInt8,1}}, ::Bool) at /data/mbauman/julia-master/usr/share/julia/site/v0.7/REPL/src/REPL.jl:706
 [26] top-level scope
@mbauman mbauman added arrays [a, r, r, a, y, s] display and printing Aesthetics and correctness of printed representations of objects. labels Feb 2, 2018
@JeffBezanson
Copy link
Member

Just tuples are enough:

julia> [(), (1,), (1,2),]
3-element Array{Tuple{Vararg{Int64,N} where N},1}:
Error showing value of type Array{Tuple{Vararg{Int64,N} where N},1}:
ERROR: BoundsError: attempt to access svec(Vararg{Int64,N} where N)
  at index [2]

Looks like some code for typeinfo that doesn't handle vararg tuple types.

@JeffBezanson JeffBezanson added the regression Regression in behavior compared to a previous version label Feb 2, 2018
@JeffBezanson
Copy link
Member

cc @rfourquet

See also #25042 #25466. The typeinfo property seems to be fundamentally broken. For it to work, every show method would need to take apart the current typeinfo type and re-set it for each sub-part it prints. That is too onerous (I wouldn't want to do it myself), so typeinfo will always get out of sync at some point in printing.

@mbauman mbauman changed the title Error displaying an array of tuples of tuples and types Error displaying an array of tuples of tuples Feb 2, 2018
@JeffBezanson
Copy link
Member

An alternate design that could work is to add a function show_with_typeinfo(io, x, T), with a fallback definition that calls show(io, x). Arrays would call show_with_typeinfo(io, elt, eltype) on their elements, and types that choose to can implement show_with_typeinfo(io, x, T), which includes the needed type destructuring. Or you can ignore it and just implement show, in which case the typeinfo is ignored and everything works as before.

@JeffBezanson JeffBezanson added this to the 1.0.x milestone Feb 4, 2018
@rfourquet
Copy link
Member

I should be able to work on the bug within two weeks.

mbauman added a commit that referenced this issue Mar 5, 2018
…luenonscalarindexedassignment

* origin/master: (28 commits)
  fix an optimizer bug in `invoke` with non-constant functions (#26301)
  lower top-level statements in such a way that the front-end knows (#26304)
  Make sure Sockets page has h1 header (#26315)
  fix doctests, and make them less prone to errors (#26275)
  FIx intro to manual chapter on types (#26312)
  Add a missing "that" (#26313)
  fix docstring for code_llvm (#26266)
  Remove the examples/ folder (#26153)
  download cert.pem from deps-getall, fixes #24903 (#25344)
  Slight update to doc string for at-enum to refer to instances (#26208)
  performance tweak in reverse(::String) (#26300)
  remove references to `TCPSocket` in Base docstrings (#26298)
  Deprecate adding integers to CartesianIndex (#26284)
  Deprecate conj(::Any), add real(::Missing) and imag(::Missing) (#26288)
  fix #26267, regression in `names` with `imported=false` (#26293)
  fix #25857, `typeinfo` problem in showing arrays with abstract tuple types (#26289)
  Add adjoint(::Missing) method (#25502)
  Use lowered form in logging macro (#26291)
  deprecate bin, oct, dec, hex, and base in favor of `string` and keyword args (#25804)
  deprecate `spawn(cmd)` to `run(cmd, wait=false)` (#26130)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrays [a, r, r, a, y, s] display and printing Aesthetics and correctness of printed representations of objects. regression Regression in behavior compared to a previous version
Projects
None yet
Development

No branches or pull requests

3 participants