Skip to content

Commit

Permalink
only warn for anon functions
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasIsensee committed Sep 13, 2024
1 parent 3647927 commit c9cbb4e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/data/writing_datatypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,11 @@ end

function h5convert!(out::Pointers, ::DataTypeODR, f::JLDFile, T::DataType, wsession::JLDWriteSession)
t = typename(T)
if T <: Function && Base.isgensym(nameof(T.instance))
@warn LazyString("Attempting to store ", T, ".\n",
"JLD2 only stores functions by name.\n",
" This may not be useful for anonymous functions.")
end
store_vlen!(out, UInt8, f, unsafe_wrap(Vector{UInt8}, t), f.datatype_wsession)
if isempty(T.parameters)
h5convert_uninitialized!(out+odr_sizeof(Vlen{UInt8}), Vlen{UInt8})
Expand Down Expand Up @@ -627,9 +632,6 @@ end
# fieldodr, but actually encoding the data for things that odr stores
# as references
@nospecializeinfer function odr(@nospecialize(T::Type))
if T <: Function
@warn LazyString("Attempting to store ", T, ".\n Function types cannot be propertly stored in JLD2 files.\n Loading may yield unexpected results.")
end
if !hasdata(T)
# A pointer singleton or ghost. We need to write something, but we'll
# just write a single byte.
Expand Down

0 comments on commit c9cbb4e

Please sign in to comment.