Skip to content

Commit

Permalink
fix roundtrip of Tuple{Type{Int}} (#485)
Browse files Browse the repository at this point in the history
Co-authored-by: Jonas Isensee <[email protected]>
  • Loading branch information
JonasIsensee and Jonas Isensee authored Sep 22, 2023
1 parent 2f9b17e commit 4abf486
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/data/writing_datatypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -356,11 +356,11 @@ const H5TYPE_DATATYPE = CompoundDatatype(
)

function h5fieldtype(f::JLDFile, ::Type{T}, readas::Type, ::Initialized) where T<:DataType
if !(readas <: DataType)
if !(readas <: DataType) || (T isa Type{Type{T}} where T)
@lookup_committed f readas
return commit(f, H5TYPE_DATATYPE, DataType, readas)
end

@lookup_committed f DataType
io = f.io
offset = f.end_of_data
Expand Down
9 changes: 7 additions & 2 deletions test/loadsave.jl
Original file line number Diff line number Diff line change
Expand Up @@ -680,5 +680,10 @@ JLD2.rconvert(::Type{OldStructVersion}, nt::NamedTuple) = OldStructVersion(nt.x,
end
end



@testset "Issue #484 round-trip Tuple{Type{Int}}" begin
cd(mktempdir()) do
T = Tuple{Type{Int}}
jldsave("test.jld2"; T)
@test T == load("test.jld2", "T")
end
end

0 comments on commit 4abf486

Please sign in to comment.