haberdashPI/MetaArrays.jl

Custom metadata example not working

Opened this issue · 1 comments

Tried to run it from readme and got the following error:

julia> struct MyCustomMetadata
         val::String
       end

julia>

julia> foo(x::MetaArray{<:Any,MyCustomMetadata}) = x.val
foo (generic function with 1 method)

julia> x = MetaArray(MyCustomMetadata("Hello, World"),1:10)
MetaArray(1:10Error showing value of type MetaArray{UnitRange{Int64}, MyCustomMetadata, Int64, 1}:
ERROR: MethodError: no method matching keys(::MyCustomMetadata)
Closest candidates are:
  keys(::Base.SkipMissing) at missing.jl:264
  keys(::Tuple) at tuple.jl:71
  keys(::Tuple, ::Tuple...) at tuple.jl:76
  ...
Stacktrace:
  [1] show(io::IOContext{Base.TTY}, #unused#::MIME{Symbol("text/plain")}, x::MetaArray{UnitRange{Int64}, MyCustomMetadata, Int64, 1})
    @ MetaArrays C:\Users\gvg\.julia\packages\MetaArrays\Kf2vb\src\MetaArrays.jl:111
  [2] (::REPL.var"#43#44"{REPL.REPLDisplay{REPL.LineEditREPL}, MIME{Symbol("text/plain")}, Base.RefValue{Any}})(io::Any)
    @ REPL C:\Julia\1.8.0\share\julia\stdlib\v1.8\REPL\src\REPL.jl:267

If I understand correctly, the issue is with show, which requires keys to be defined. The meta array is created as expected