From 95e32aa525be3649d0671ce3e47efb6e38382421 Mon Sep 17 00:00:00 2001 From: "Killian Q. Zhuo" Date: Wed, 5 Apr 2023 20:16:26 +0800 Subject: [PATCH] Fix #161 (#162) * Fix #161 * TypedSlot is in Core.Compiler in Julia v1.10 * Update src/Libtask.jl Co-authored-by: David Widmann * Update Project.toml --------- Co-authored-by: Hong Ge <3279477+yebai@users.noreply.github.com> Co-authored-by: David Widmann --- Project.toml | 2 +- src/Libtask.jl | 7 +++++++ src/tapedfunction.jl | 8 ++++---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Project.toml b/Project.toml index b8ad8d1..cd87c25 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.5" +version = "0.8.6" [deps] FunctionWrappers = "069b7b12-0de2-55c6-9aab-29f3d0a68a2e" diff --git a/src/Libtask.jl b/src/Libtask.jl index 48a8e49..6f6985c 100644 --- a/src/Libtask.jl +++ b/src/Libtask.jl @@ -7,6 +7,13 @@ export TapedTask, consume, produce export TArray, tzeros, tfill, TRef # legacy types back compat + +const TypedSlot = @static if isdefined(Core, :TypedSlot) # Julia v1.10 removed Core.TypedSlot + Core.TypedSlot +else + Core.Compiler.TypedSlot +end + include("tapedfunction.jl") include("tapedtask.jl") diff --git a/src/tapedfunction.jl b/src/tapedfunction.jl index c978384..e5eeef2 100644 --- a/src/tapedfunction.jl +++ b/src/tapedfunction.jl @@ -285,7 +285,7 @@ function bind_var!(var::QuoteNode, bindings::Bindings, ir::Core.CodeInfo) LOGGING[] && @info "evaluating QuoteNode $var at compile time" bind_var!(eval(var), bindings, ir) end -function bind_var!(var::Core.TypedSlot, bindings::Bindings, ir::Core.CodeInfo) +function bind_var!(var::TypedSlot, bindings::Bindings, ir::Core.CodeInfo) # turn TypedSlot to SlotNumber bind_var!(Core.SlotNumber(var.id), bindings, ir) end @@ -295,9 +295,9 @@ end function bind_var!(var::Core.SSAValue, bindings::Bindings, ir::Core.CodeInfo) get!(bindings[1], var, allocate_binding!(var, bindings, ir.ssavaluetypes[var.id])) end - allocate_binding!(var, bindings::Bindings, c::Core.Const) = - allocate_binding!(var, bindings, _loose_type(Type{c.val})) + allocate_binding!(var, bindings, _loose_type(Type{_accurate_typeof(c.val)})) + allocate_binding!(var, bindings::Bindings, c::Core.PartialStruct) = allocate_binding!(var, bindings, _loose_type(c.typ)) function allocate_binding!(var, bindings::Bindings, ::Type{T}) where T @@ -378,7 +378,7 @@ function translate!!(var::IRVar, line::NTuple{N, Symbol}, return Instruction(func, input, output) end -function translate!!(var::IRVar, line::Core.TypedSlot, +function translate!!(var::IRVar, line::TypedSlot, bindings::Bindings, isconst::Bool, ir) input_box = bind_var!(Core.SlotNumber(line.id), bindings, ir) return Instruction(identity, (input_box,), bind_var!(var, bindings, ir))