Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/refelim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ function eliminate_refs(ir::BBCode, refs::Tuple)
# %1 = set_ref_at!(_1, refid, Main.a)
# can be replaced with
# %1 = Main.a
# In theory we could eliminate the SSA ID entirely and replace
# all uses of it with the GlobalRef/Argument directly. We'll
# leave that optimisation to the Julia compiler though.
refid_to_ssaid_map[refid] = id
push!(new_insts, (id, new_inst(value_arg)))
else
Expand All @@ -253,7 +256,7 @@ function eliminate_refs(ir::BBCode, refs::Tuple)
ssaid = get(old_ssaid_to_new_ssaid_map, value_arg, value_arg)
refid_to_ssaid_map[refid] = ssaid
elseif value_arg isa GlobalRef || value_arg isa Argument
# Create a new SSA ID that points to the GlobalRef.
# Create a new SSA ID that points to the thing.
new_id = ID()
push!(new_insts, (new_id, new_inst(value_arg)))
refid_to_ssaid_map[refid] = new_id
Expand Down
14 changes: 11 additions & 3 deletions test/copyable_task.jl
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,19 @@ __global_a = 1.0
end
@testset "Return produce" begin
# Test calling a function that does something with the return value of `produce`.
# In this case it just returns it. This used to error, see
# https://github.com/TuringLang/Libtask.jl/issues/190.
f(obs) = produce(obs)
# This used to error, see https://github.com/TuringLang/Libtask.jl/issues/190.
function f(obs)
x = produce(obs)
# produce(x) returns x
return if isnothing(x)
produce(1.0)
else
produce(x)
end
end
tt = Libtask.TapedTask(nothing, f, :a)
@test Libtask.consume(tt) === :a
@test Libtask.consume(tt) === :a
@test Libtask.consume(tt) === nothing
end

Expand Down
Loading