Skip to content

StrPack fails to unpack #23

@kuldeepdhaka

Description

@kuldeepdhaka
using StrPack

@struct type Apple
    sweet::Float32
end

@struct type Boy
    eat::Apple
end

@struct type Cat
    home::Boy
end

c = Cat(Boy(Apple(0f0)))

ib = IOBuffer()
pack(ib, c)

seek(ib, 0)
unpack(ib, Cat)

results:

ERROR: LoadError: MethodError: Cannot `convert` an object of type Type{Apple} to an object of type StrPack.Struct
This may have arisen from a call to the constructor StrPack.Struct(...),
since type constructors fall back to convert methods.
Closest candidates are:
  StrPack.Struct(::Any, !Matched::Any, !Matched::Any)
  call{T}(::Type{T}, ::Any)
  convert{T}(::Type{T}, !Matched::T)
  ...
 in calcsize at /home/kuldeep/.julia/v0.5/StrPack/src/StrPack.jl:342
 [inlined code] from dict.jl:723
 in calcsize at /home/kuldeep/.julia/v0.5/StrPack/src/StrPack.jl:350
 in unpack at /home/kuldeep/.julia/v0.5/StrPack/src/StrPack.jl:175
 in unpack at /home/kuldeep/.julia/v0.5/StrPack/src/StrPack.jl:196
 in include at ./boot.jl:262
 in include_from_node1 at ./loading.jl:401
 in process_options at ./client.jl:245
 in _start at ./client.jl:301
while loading /home/kuldeep/Desktop/break.jl, in expression starting on line 21

can anybody explain why it failed?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions