diff --git a/Project.toml b/Project.toml index 85c389e..febafd4 100644 --- a/Project.toml +++ b/Project.toml @@ -3,7 +3,7 @@ uuid = "6f1fad26-d15e-5dc8-ae53-837a1d7b8c9f" license = "MIT" desc = "Tape based task copying in Turing" repo = "https://github.com/TuringLang/Libtask.jl.git" -version = "0.8.1" +version = "0.8.2" [deps] FunctionWrappers = "069b7b12-0de2-55c6-9aab-29f3d0a68a2e" diff --git a/src/tapedfunction.jl b/src/tapedfunction.jl index 1f78c42..8f2e27b 100644 --- a/src/tapedfunction.jl +++ b/src/tapedfunction.jl @@ -369,6 +369,15 @@ function translate!!(var::IRVar, line::Core.SlotNumber, return Instruction(func, input, output) end +function translate!!(var::IRVar, line::NTuple{N, Symbol}, + bindings::Bindings, isconst::Bool, ir) where {N} + # for syntax (; x, y, z), see Turing.jl#1873 + func = identity + input = (bind_var!(line, bindings, ir),) + output = bind_var!(var, bindings, ir) + return Instruction(func, input, output) +end + function translate!!(var::IRVar, line::Core.TypedSlot, bindings::Bindings, isconst::Bool, ir) input_box = bind_var!(Core.SlotNumber(line.id), bindings, ir) @@ -437,7 +446,7 @@ function translate!!(var::IRVar, line::Expr, end end -function translate!!(var, line, bindings, ir) +function translate!!(var, line, bindings, isconst, ir) @error "Unknown IR code: " typeof(var) var typeof(line) line throw(ErrorException("Unknown IR code")) end diff --git a/test/issues.jl b/test/issues.jl index 7a9d295..f9deeff 100644 --- a/test/issues.jl +++ b/test/issues.jl @@ -48,4 +48,15 @@ ttask = TapedTask(f, 2) @test consume(ttask) == 1 end + + @testset "Issue-Turing-1873, NamedTuple syntax" begin + function g(x, y) + c = x + y + return (; c, x, y) + end + + tf = Libtask.TapedFunction(g, 1, 2) + r = tf(1, 2) + @test r == (c=3, x=1, y=2) + end end