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

Failure to save struct parameterized on Union containing UnionAlls. #109

Closed
KristofferC opened this issue Sep 7, 2018 · 0 comments · Fixed by #206
Closed

Failure to save struct parameterized on Union containing UnionAlls. #109

KristofferC opened this issue Sep 7, 2018 · 0 comments · Fixed by #206

Comments

@KristofferC
Copy link
Member

KristofferC commented Sep 7, 2018

Reported in KristofferC/NearestNeighbors.jl#71 (comment).

MWE:

using JLD2
struct Foo end
struct Bar{T} end
struct Baz{T <: Union{Foo, Bar}} end
@save "foo.jld2" Baz

gives:

ERROR: MethodError: Cannot `convert` an object of type Type{Bar} to an object of type DataType
Closest candidates are:
  convert(::Type{T}, ::T) where T at essentials.jl:154
Stacktrace:
 [1] setindex!(::Array{DataType,1}, ::Type, ::Int64) at ./array.jl:769
 [2] copyto!(::IndexLinear, ::Array{DataType,1}, ::IndexLinear, ::Array{Any,1}) at ./abstractarray.jl:731
 [3] copyto! at ./abstractarray.jl:723 [inlined]
 [4] Type at ./array.jl:497 [inlined]
 [5] h5convert!(::JLD2.IndirectPointer, ::Type{JLD2.Vlen{JLD2.OnDiskRepresentation{(0, 16),Tuple{String,Array{Any,1}},Tuple{JLD2.Vlen{String},JLD2.Vlen{JLD2.RelOffset}}}()}}, ::JLD2.JLDFile{JLD2.MmapIO}, ::Union, ::JLD2.JLDWriteSession{Dict{UInt64,JLD2.RelOffset}}) at /Users/kristoffer/.julia/packages/JLD2/KjBIK/src/data.jl:964

Seems like a Vector{DataType} is allocated and then the UnionAll is assigned to that which doesn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants