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

Fix unions for upgrades on mutable structs #629

Merged
merged 4 commits into from
Jan 14, 2025
Merged

Conversation

IanButterworth
Copy link
Member

Fixes #628

It's a bit of a guess, but tests pass for me locally, including the test added here, which reproduces the issue on master for mutable structs.

On master

Error encountered while load File{DataFormat{:JLD2}, String}("a.jld2").

Fatal error:
mutable: Error During Test at /Users/ian/Documents/GitHub/JLD2.jl/test/loadsave.jl:750
  Got exception outside of a @test
  TypeError: in Union, expected Type, got a value of type JLD2.Upgrade
  Stacktrace:
    [1] jlconvert(::JLD2.MappedRepr{Union, JLD2.OnDiskRepresentation{(0, 16, 32), Tuple{String, Vector{Any}, Vector{Any}}, Tuple{JLD2.Vlen{String}, JLD2.Vlen{JLD2.RelOffset}, JLD2.Vlen{JLD2.RelOffset}}, 48}}, f::JLD2.JLDFile{JLD2.MmapIO}, ptr::Ptr{Nothing}, header_offset::JLD2.RelOffset)
      @ JLD2 ~/Documents/GitHub/JLD2.jl/src/data/writing_datatypes.jl:549
    [2] read_scalar(f::JLD2.JLDFile{JLD2.MmapIO}, rr::Any, header_offset::JLD2.RelOffset)
      @ JLD2 ~/Documents/GitHub/JLD2.jl/src/io/dataio.jl:107
...
Test Summary:                                     | Pass  Error  Total  Time
Issue #628 Upgrading structs that contains unions |    3      1      4  1.8s
  immutable                                       |    3             3  0.4s
  mutable                                         |           1      1  1.0s
ERROR: LoadError: Some tests did not pass: 3 passed, 0 failed, 1 errored, 0 broken.
in expression starting at /Users/ian/Documents/GitHub/JLD2.jl/test/loadsave.jl:740
in expression starting at /Users/ian/Documents/GitHub/JLD2.jl/test/runtests.jl:25
ERROR: Package JLD2 errored during testing

cc. @Octogonapus

Copy link

codecov bot commented Jan 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.81%. Comparing base (b8b0f9a) to head (fb669c3).
Report is 8 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #629      +/-   ##
==========================================
+ Coverage   84.77%   84.81%   +0.04%     
==========================================
  Files          37       37              
  Lines        4242     4241       -1     
==========================================
+ Hits         3596     3597       +1     
+ Misses        646      644       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@JonasIsensee JonasIsensee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
This is probably what I would have done as well.

This change make the checking for Upgrade in line 357 unnecessary.
That should probably be removed together with this change.

@JonasIsensee JonasIsensee merged commit 7b18630 into master Jan 14, 2025
15 checks passed
@IanButterworth IanButterworth deleted the ib/fix_union_upgrade branch January 14, 2025 14:10
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 this pull request may close these issues.

Bug in Union loading using Upgrade
2 participants