Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update type mutability check in IO.jl #409

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ RecipesBase = "0.7,1"
StatsBase = "0.32,0.33"
TextParse = "0.9.1,1"
WeakRefStrings = "0.6"
julia = "1"
julia = "1.6"
Copy link
Collaborator

Choose a reason for hiding this comment

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

ismutabletype requires Julia 1.7

Copy link
Author

Choose a reason for hiding this comment

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

Does it make sense to define a mutability check function that checks the Julia version and runs a compatible version of the test?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The source of ismutabletype looks pretty simple. We just need something like:

ismutabletype = if VERSION < v"1.7"
    function ismutabletype(@nospecialize(t::Type))
        t = unwrap_unionall(t)
        return isa(t, DataType) && t.name.flags & 0x2 == 0x2
    end
else
    Base.ismutabletype
end

Copy link
Author

Choose a reason for hiding this comment

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

done


[extras]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down
2 changes: 1 addition & 1 deletion src/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ deserialize(io::AbstractSerializer, DT::Type{DIndexedTable{T,K}}) where {T,K} =
function _deser(io::AbstractSerializer, t)
nf = fieldcount(t)
x = ccall(:jl_new_struct_uninit, Any, (Any,), t)
t.mutable && Serialization.deserialize_cycle(io, x)
ismutabletype(t) && Serialization.deserialize_cycle(io, x)
for i in 1:nf
tag = Int32(read(io.io, UInt8)::UInt8)
if tag != Serialization.UNDEFREF_TAG
Expand Down