Skip to content

Commit 0355eab

Browse files
Update mappingx
1 parent f4941a0 commit 0355eab

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/tapedfunction.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,16 @@ function copy_bindings(old::Dict{Symbol, Any})
373373
return newb
374374
end
375375

376-
function Base.copy(tf::TapedFunction)
376+
function Base.copy(tf::TapedFunction, args...)
377377
# create a new uninitialized TapedFunction
378378
new_tf = TapedFunction(tf)
379379
new_tf.bindings = copy_bindings(tf.bindings)
380+
if !isempty(args)
381+
length(args) > tf.arity && throw("Number of updates for `args` is greater than generated function arity $(tf.arity)")
382+
for (i, arg) in enumerate(args)
383+
slot = Symbol("_", i + 1)
384+
haskey(tf.bindings, slot) && _update_var!(tf, slot, arg)
385+
end
386+
end
380387
return new_tf
381388
end

src/tapedtask.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ Base.IteratorEltype(::Type{<:TapedTask}) = Base.EltypeUnknown()
159159

160160
# copy the task
161161

162-
function Base.copy(t::TapedTask)
163-
tf = copy(t.tf)
164-
new_t = TapedTask(tf)
162+
function Base.copy(t::TapedTask, args...)
163+
tf = copy(t.tf, args...)
164+
new_t = TapedTask(tf, args...)
165165
storage = t.task.storage::IdDict{Any,Any}
166166
new_t.task.storage = copy(storage)
167167
new_t.task.storage[:tapedtask] = new_t

0 commit comments

Comments
 (0)