diff --git a/src/data/number_types.jl b/src/data/number_types.jl index 176c0785..71a80361 100644 --- a/src/data/number_types.jl +++ b/src/data/number_types.jl @@ -37,7 +37,7 @@ function jltype(f::JLDFile, dt::FixedPointDatatype) elseif dt.size == 1 return signed ? SameRepr{Int8}() : SameRepr{UInt8}() elseif dt.size == 4 - return signed ? SameRepr{Int32}() : SameRepr{Int32}() + return signed ? SameRepr{Int32}() : SameRepr{UInt32}() elseif dt.size == 2 return signed ? SameRepr{Int16}() : SameRepr{UInt16}() elseif dt.size == 16 diff --git a/test/loadsave.jl b/test/loadsave.jl index 5b3decaf..5a3e00f1 100644 --- a/test/loadsave.jl +++ b/test/loadsave.jl @@ -847,4 +847,21 @@ end loaded_data = load(fn, "data") @test !isassigned(loaded_data, 2) @test loaded_data[1] == :a -end \ No newline at end of file +end + +@testset "Issue #619 - Number type turnaround" begin + fn = joinpath(mktempdir(), "number_type_turnaround.jld2") + types = [UInt8, Int8, UInt16, Int16, UInt32, Int32, UInt64, Int64, UInt128, Int128, Float16, Float32, Float64] + jldopen(fn, "w") do f + for t in types + f[string(t)] = typemax(t) + end + end + jldopen(fn) do f + for t in types + v = f[string(t)] + @test v isa t + @test v == typemax(t) + end + end +end