From 4c549350df8467a59f49b8e64f82fb34de86c4a6 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Thu, 11 May 2017 10:40:59 -0400 Subject: [PATCH] fix #21793, regression in serializing nested closure --- base/serialize.jl | 3 ++- test/serialize.jl | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/base/serialize.jl b/base/serialize.jl index 4b309489226c9..d453e9e0a33f9 100644 --- a/base/serialize.jl +++ b/base/serialize.jl @@ -703,7 +703,8 @@ function handle_deserialize(s::AbstractSerializer, b::Int32) return GlobalRef(deserialize(s)::Module, deserialize(s)::Symbol) elseif b == FULL_GLOBALREF_TAG ty = deserialize(s) - return GlobalRef(ty.name.module, ty.name.name) + tn = unwrap_unionall(ty).name + return GlobalRef(tn.module, tn.name) elseif b == LONGTUPLE_TAG return deserialize_tuple(s, Int(read(s.io, Int32)::Int32)) elseif b == LONGEXPR_TAG diff --git a/test/serialize.jl b/test/serialize.jl index 8be0c8f0d0a35..b136ad7b40425 100644 --- a/test/serialize.jl +++ b/test/serialize.jl @@ -300,6 +300,15 @@ main_ex = quote $Test.@test g2() == :magic_token_anon_fun_test $Test.@test g2() == :magic_token_anon_fun_test $Test.@test deserialize(ds) === g2 + + # issue #21793 + y = x -> (() -> x) + seekstart(s) + serialize(s, y) + seekstart(s) + y2 = deserialize(s) + x2 = y2(2) + $Test.@test x2() == 2 end end # This needs to be run on `Main` since the serializer treats it differently.