Skip to content

Commit 6a56807

Browse files
committed
Add a test
1 parent 2d05141 commit 6a56807

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/copyable_task.jl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,4 +300,31 @@
300300
@test Libtask.consume(tt) === 10
301301
@test Libtask.consume(tt) === nothing
302302
end
303+
304+
# Regression test against https://github.com/TuringLang/Libtask.jl/issues/207
305+
@testset "Union deferencing" begin
306+
function g(i::Int)
307+
produce(1)
308+
return i
309+
end
310+
function g(s::String)
311+
produce(2)
312+
return s
313+
end
314+
Libtask.@might_produce g
315+
316+
h(i::Int)::Int = i
317+
h(s::String)::Int = length(s)
318+
319+
function f(x, g)
320+
i_or_s = x > 0 ? 3 : "libtask"
321+
gres = g(i_or_s)
322+
return h(gres)
323+
end
324+
325+
t = TapedTask(nothing, f, 1, g)
326+
consume(t)
327+
# This used to error
328+
@test (consume(t); true)
329+
end
303330
end

0 commit comments

Comments
 (0)