-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
Libtask.jl/src/copyable_task.jl
Lines 74 to 88 in f154425
function build_callable(sig::Type{<:Tuple}) | |
if sig <: Tuple{typeof(produce),Any} | |
msg = """ | |
Can not construct a TapedTask for a 'naked' call to `produce`. | |
Please wrap the call to `produce` in a function, and construct a | |
TapedTask from that function.""" | |
throw(ArgumentError(msg)) | |
end | |
key = CacheKey(Base.get_world_counter(), sig) | |
if haskey(mc_cache, key) | |
return fresh_copy(mc_cache[key]) | |
else | |
ir = Base.code_ircode_by_type(sig)[1][1] | |
# Check whether this is a varargs call. | |
isva = which(sig).isva |
If Libtask attempts to construct IR for an ambiguous method, line 86 here will error with something like this. It's at least not impossible to guess where is going wrong (based on the signature in [4]), but the error message could definitely be improved here too.
ERROR: BoundsError: attempt to access 0-element Vector{Any} at index [1]
Stacktrace:
[1] throw_boundserror(A::Vector{Any}, I::Tuple{Int64})
@ Base ./essentials.jl:14
[2] getindex
@ ./essentials.jl:916 [inlined]
[3] build_callable(sig::Type{Tuple{…}})
@ Libtask ~/.julia/packages/Libtask/Sf4tJ/src/copyable_task.jl:86
[4] (::Libtask.DynamicCallable{…})(::Function, ::Turing.Inference.ParticleMCMCContext{…}, ::Cauchy{…}, ::Float64, ::AbstractPPL.VarName{…}, ::DynamicPPL.VarInfo{…})
@ Libtask ~/.julia/packages/Libtask/Sf4tJ/src/copyable_task.jl:1163
[5] f
@ ./REPL[6]:1 [inlined]
[6] (::Tuple{…})(none::typeof(f), none::DynamicPPL.Model{…}, none::DynamicPPL.VarInfo{…}, none::Float64)
@ Base.Experimental ./<missing>:0
[7] consume
@ ~/.julia/packages/Libtask/Sf4tJ/src/copyable_task.jl:347 [inlined]
[8] advance!(trace::AdvancedPS.Trace{AdvancedPS.LibtaskModel{…}, AdvancedPS.TracedRNG{…}}, isref::Bool)
@ Turing.Inference ~/ppl/lib/src/mcmc/particle_mcmc.jl:68
[9] reweight!(pc::AdvancedPS.ParticleContainer{AdvancedPS.Trace{…}, AdvancedPS.TracedRNG{…}}, ref::Noth
Metadata
Metadata
Assignees
Labels
No labels