Libtask.jl
Libtask.jl copied to clipboard
Nicer error for ambiguous methods
https://github.com/TuringLang/Libtask.jl/blob/f154425829d19eefa0dfbfff528a1c6c61da49e1/src/copyable_task.jl#L74-L88
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