JuliaData / FlatBuffers.jl

A pure Julia implementation of google flatbuffers
https://juliadata.github.io/FlatBuffers.jl/stable
Other
43 stars 14 forks source link

show() is broken for vectors #25

Open Chunkulator opened 6 years ago

Chunkulator commented 6 years ago

FlatBuffers correctly builds flatbuffer representations of vectors but fails to show() them.

julia> versioninfo()
Julia Version 0.6.1
Commit 0d7248e (2017-10-24 22:15 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin14.5.0)
  CPU: Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Prescott)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, broadwell)

julia> using FlatBuffers

julia> flatbuffer = FlatBuffers.build!([1;2;3;4])
FlatBuffers.FlatBuffers.Builder{Array{Int64,1}}: 
Error showing value of type FlatBuffers.Builder{Array{Int64,1}}:
ERROR: ArgumentError: reducing over an empty collection is not allowed
Stacktrace:
 [1] _mapreduce(::Base.#identity, ::Base.#scalarmax, ::IndexLinear, ::Array{Any,1}) at ./reduce.jl:265
 [2] show(::IOContext{Base.Terminals.TTYTerminal}, ::FlatBuffers.Builder{Array{Int64,1}}) at /Users/rcart/.julia/v0.6/FlatBuffers/src/FlatBuffers.jl:95
 [3] display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::MIME{Symbol("text/plain")}, ::FlatBuffers.Builder{Array{Int64,1}}) at ./REPL.jl:122
 [4] display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::FlatBuffers.Builder{Array{Int64,1}}) at ./REPL.jl:125
 [5] display(::FlatBuffers.Builder{Array{Int64,1}}) at ./multimedia.jl:194
 [6] eval(::Module, ::Any) at ./boot.jl:235
 [7] print_response(::Base.Terminals.TTYTerminal, ::Any, ::Void, ::Bool, ::Bool, ::Void) at ./REPL.jl:144
 [8] print_response(::Base.REPL.LineEditREPL, ::Any, ::Void, ::Bool, ::Bool) at ./REPL.jl:129
 [9] (::Base.REPL.#do_respond#16{Bool,Base.REPL.##26#36{Base.REPL.LineEditREPL,Base.REPL.REPLHistoryProvider},Base.REPL.LineEditREPL,Base.LineEdit.Prompt})(::Base.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at ./REPL.jl:646
rjkat commented 5 years ago

This is related to issue #29. Basically the show method assumes that what’s in the buffer has a vtable i.e. it’s a “table” object. Unless there is a compelling use case here, I’d say it’s unlikely that this project will support non-standard behaviour. Stay tuned for a PR on the official flatc adding julia code generation.