diff --git a/src/RuntimeGeneratedFunctions.jl b/src/RuntimeGeneratedFunctions.jl index 5624dc2..d8c847c 100644 --- a/src/RuntimeGeneratedFunctions.jl +++ b/src/RuntimeGeneratedFunctions.jl @@ -376,6 +376,9 @@ function Serialization.deserialize(s::AbstractSerializer, B === Nothing ? drop_expr(f) : f end +# achieve deepcopy(f)===f behavior similar to "normal" julia functions +Base.deepcopy_internal(f::RuntimeGeneratedFunction, stackdict::IdDict) = f + @specialize end diff --git a/test/runtests.jl b/test/runtests.jl index 536876b..3db5a76 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -184,3 +184,8 @@ deserialized_f, deserialized_g = deserialize(buf) @test deserialized_f.body isa Expr @test deserialized_g(12) == "Serialization with dropped body. y=12" @test deserialized_g.body isa Nothing + +# deepcopy +ff = @RuntimeGeneratedFunction(:(x -> [x, x+1])) +@test deepcopy(ff) == ff +@test deepcopy(ff) === ff