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

Saving/Reloading a struct with more than 255 fields leads to a "missing field" warning & corrupted loads #558

Closed
ChristianBayerEcon opened this issue May 10, 2024 · 1 comment · Fixed by #559

Comments

@ChristianBayerEcon
Copy link

A minimum working example is the following:

using JLD2

# Define a struct with 256 fields
count=256
fields = [Symbol("field",i) for i in 1:count]
@eval struct MyStruct
    $(fields...)
end

# Fill the struct
myStructInstance = MyStruct(ntuple(i -> i, count)...)

# Save the struct
@save "myStruct.jld2" myStructInstance

# Load the struct
@load "myStruct.jld2" myStructInstance

if count is 255 this works as expected but with 256 the following error occurs

┌ Warning: saved type MyStruct is missing field field1 in workspace type; reconstructing
└ @ JLD2 ~/.julia/packages/JLD2/VWinU/src/data/reconstructing_datatypes.jl:207

The resulting load is an empty struct

julia> myStructInstance
Reconstruct@MyStruct(())

Julia is 1.10 and JLD2 is the most recent version.

Is this a known bug? Or do I need to change any parameters of the @save command? (using jldsave/jldopen results in the same behavior)

@JonasIsensee
Copy link
Collaborator

Fascinating. That wasn't a known bug so faf. I'll try to fix it in the next few days.

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

Successfully merging a pull request may close this issue.

2 participants