diff --git a/Project.toml b/Project.toml index 7d871e50..b8ad8d18 100644 --- a/Project.toml +++ b/Project.toml @@ -3,7 +3,7 @@ uuid = "6f1fad26-d15e-5dc8-ae53-837a1d7b8c9f" license = "MIT" desc = "Tape based task copying in Turing" repo = "https://github.com/TuringLang/Libtask.jl.git" -version = "0.8.4" +version = "0.8.5" [deps] FunctionWrappers = "069b7b12-0de2-55c6-9aab-29f3d0a68a2e" diff --git a/src/tapedfunction.jl b/src/tapedfunction.jl index 963fea47..c9783841 100644 --- a/src/tapedfunction.jl +++ b/src/tapedfunction.jl @@ -476,9 +476,9 @@ function tape_shallowcopy end, function tape_deepcopy end tape_shallowcopy(x) = x tape_deepcopy(x) = deepcopy(x) + # Core.Box is used as closure captured variable container, so we should tape_copy its contents -tape_shallowcopy(x::Core.Box) = Core.Box(tape_shallowcopy(x.contents)) -tape_deepcopy(x::Core.Box) = Core.Box(tape_deepcopy(x.contents)) +_tape_copy(box::Core.Box, deepcopy_types) = Core.Box(_tape_copy(box.contents, deepcopy_types)) function _tape_copy(v, deepcopy_types) if isa(v, deepcopy_types)