From 4abf4861e8f67c35eb5079629a22ea128e7b6363 Mon Sep 17 00:00:00 2001 From: JonasIsensee Date: Fri, 22 Sep 2023 09:19:03 +0200 Subject: [PATCH] fix roundtrip of Tuple{Type{Int}} (#485) Co-authored-by: Jonas Isensee --- src/data/writing_datatypes.jl | 4 ++-- test/loadsave.jl | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/data/writing_datatypes.jl b/src/data/writing_datatypes.jl index 59dff91a..6b6e1f35 100644 --- a/src/data/writing_datatypes.jl +++ b/src/data/writing_datatypes.jl @@ -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 diff --git a/test/loadsave.jl b/test/loadsave.jl index 73e221d0..6135b7b6 100644 --- a/test/loadsave.jl +++ b/test/loadsave.jl @@ -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