From c9cbb4e1b5b56570b20cac25201a66c9d81d0579 Mon Sep 17 00:00:00 2001 From: Jonas Isensee Date: Fri, 13 Sep 2024 09:48:23 +0200 Subject: [PATCH] only warn for anon functions --- src/data/writing_datatypes.jl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/data/writing_datatypes.jl b/src/data/writing_datatypes.jl index 68570202..f1fdc0b6 100644 --- a/src/data/writing_datatypes.jl +++ b/src/data/writing_datatypes.jl @@ -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}) @@ -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.