diff --git a/base/serialize.jl b/base/serialize.jl index 752d06da984d2..aeb6e89adb43a 100644 --- a/base/serialize.jl +++ b/base/serialize.jl @@ -529,7 +529,7 @@ function deserialize(s::SerializationState, ::Type{Function}) f.env = deserialize(s) return f end - + deserialize_cycle(s, f) return f end diff --git a/test/serialize.jl b/test/serialize.jl index 0d5a6554c04fc..1b63b7fe25734 100644 --- a/test/serialize.jl +++ b/test/serialize.jl @@ -280,16 +280,34 @@ create_serialization_stream() do s end # cycles +module CycleFoo + echo(x)=x +end create_serialization_stream() do s - A = Any[1,2,3,4,5] + echo(x) = x + afunc = (x)->x + A = Any[1,2,3,abs,abs,afunc,afunc,echo,echo,CycleFoo.echo,CycleFoo.echo,4,5] A[3] = A serialize(s, A) seekstart(s) b = deserialize(s) @test b[3] === b @test b[1] == 1 - @test b[5] == 5 - @test length(b) == 5 + @test b[4] === abs + @test b[5] === b[4] + @test b[5](-1) == 1 + + @test b[6] === b[7] + @test b[6]("Hello") == "Hello" + + @test b[8] === b[9] + @test b[8]("World") == "World" + + @test b[10] === b[11] + @test b[10]("foobar") == "foobar" + + @test b[end] == 5 + @test length(b) == length(A) @test isa(b,Vector{Any}) end