Skip to content

Commit 6a864c0

Browse files
authored
Fix #142 (#144)
* Fix #142 * populate args * deal with unused args
1 parent 1cecf7d commit 6a864c0

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/tapedtask.jl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,20 @@ function Base.copy(t::TapedTask; args=())
166166
error("can't copy started task with new arguments")
167167
tf = copy(t.tf)
168168
task_args = if length(args) > 0
169+
# this cond implies t.tf.counter == 0, i.e., the task is not started yet
169170
typeof(args) == typeof(t.args) || error("bad arguments")
170171
args
171172
else
172-
tape_copy.(t.args)
173+
if t.tf.counter > 1
174+
# the task is running, we find the
175+
# real args from the copied bindings
176+
map(1:length(t.args)) do i
177+
get(tf.bindings, Symbol("_", i + 1), t.args[i])
178+
end
179+
else
180+
# the task is not started yet, but no args is given
181+
tape_copy.(t.args)
182+
end
173183
end
174184
new_t = TapedTask(tf, task_args...)
175185
storage = t.task.storage::IdDict{Any,Any}

0 commit comments

Comments
 (0)