Skip to content

Commit fa576f8

Browse files
authored
Fix #207 (#209)
* Attempt to fix #207 * Add a test * Bump patch version to 0.9.10
1 parent a3e259e commit fa576f8

File tree

4 files changed

+34
-3
lines changed

4 files changed

+34
-3
lines changed

HISTORY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.9.10
2+
3+
Fix a bug introduced in 0.9.9 that made certain phi nodes with Union types fail a type assertion.
4+
15
# 0.9.9
26

37
Remove manual opaque closure optimisation functions in favour of setting the world age and letting the compiler do more work for us, and providing it with some more type information. This changes no functionality, and shouldn't change performance either, but simplifies code.

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ uuid = "6f1fad26-d15e-5dc8-ae53-837a1d7b8c9f"
33
license = "MIT"
44
desc = "Tape based task copying in Turing"
55
repo = "https://github.com/TuringLang/Libtask.jl.git"
6-
version = "0.9.9"
6+
version = "0.9.10"
77

88
[deps]
99
MistyClosures = "dbe65cb8-6be2-42dd-bbc5-4196aaced4f4"

src/copyable_task.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,8 +1226,8 @@ end
12261226

12271227
# Helper used in `derive_copyable_task_ir`.
12281228
@inline function deref_phi(refs::R, n::TupleRef, ::Type{T}) where {R<:Tuple,T}
1229-
ref = refs[n.n]::Base.RefValue{T}
1230-
return ref[]
1229+
ref = refs[n.n]
1230+
return ref[]::T
12311231
end
12321232
@inline deref_phi(::R, x, t::Type) where {R<:Tuple} = x
12331233

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)