Skip to content

Commit

Permalink
Fix union{} (#534)
Browse files Browse the repository at this point in the history
* Union{} is weird

* add test

* version and changelog
  • Loading branch information
JonasIsensee authored Jan 16, 2024
1 parent 3e14317 commit 15eaa50
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.4.44
- fix dispatch around `Union{}` as type parameter

## 0.4.43
- do not try to `rconvert` `#undef` array elements (#529)

Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "JLD2"
uuid = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
version = "0.4.43"
version = "0.4.44"

[deps]
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
Expand Down
2 changes: 2 additions & 0 deletions src/data/reconstructing_datatypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ end

isunknowntype(x::Type{<:UnknownType}) = true
isunknowntype(x) = false
isunknowntype(::Type{Union{}}) = false

function _resolve_type(rr::ReadRepresentation{T,DataTypeODR()},
f::JLDFile,
Expand Down Expand Up @@ -475,6 +476,7 @@ end
isreconstructed(x) = isreconstructed(typeof(x))
isreconstructed(x::Type{<:AbstractReconstructedType}) = true
isreconstructed(x::Type) = false
isreconstructed(x::Type{Union{}}) = false

function reconstruct_bitstype(name::Union{Symbol,String}, size::Integer, empty::Bool)
if empty
Expand Down
8 changes: 8 additions & 0 deletions test/loadsave.jl
Original file line number Diff line number Diff line change
Expand Up @@ -731,4 +731,12 @@ end
@test load(fn, "b/d/f", "a") == (Dict("g" => 4), 1)
@test load(fn, "b/d") == Dict("e" => 3, "f" => Dict("g"=> 4))
end
end

@testset "Union{} in type signature Issue #532" begin
cd(mktempdir()) do
op = (1, pairs((;)))
jldsave("testopempty.jld2"; op)
@test op == load("testopempty.jld2", "op")
end
end

2 comments on commit 15eaa50

@JonasIsensee
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/98949

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.4.44 -m "<description of version>" 15eaa50927e91bc72f0be2112035a1c1a67901ff
git push origin v0.4.44

Please sign in to comment.