From 96459fd724b7f56b9ea0fea4db82ab865e770530 Mon Sep 17 00:00:00 2001 From: Jonas Isensee Date: Thu, 21 Sep 2023 14:26:09 +0200 Subject: [PATCH] fix roundtrip of Tuple{Type{Int}} --- 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