Skip to content

DynamicCallable issue with varargs #186

@mhauru

Description

@mhauru

MWE:

julia> function g()
                  if randn() > 0
                      f = Base.vect
                  else
                      f = tuple
                  end
                  produce(f(0.1, 0.2))
              end
g (generic function with 1 method)

julia> show(Libtask.consume(Libtask.TapedTask(nothing, g)))
ERROR: MethodError: no method matching (::Core.OpaqueClosure{Tuple{typeof(Base.vect), Tuple{…}}, Vector{Float64}})(::typeof(Base.vect), ::Float64, ::Float64)
This error has been manually thrown, explicitly, so the method may exist but be intentionally marked as unimplemented.

Closest candidates are:
  (::Core.OpaqueClosure{Tuple{typeof(Base.vect), Tuple{Float64, Float64}}, Vector{Float64}})(::typeof(Base.vect), ::Tuple{Float64, Float64}) (method too new to be called from this world context.)
   @ Core :0

Stacktrace:
 [1] (::MistyClosures.MistyClosure{Core.OpaqueClosure{Tuple{…}, Vector{…}}})(::Function, ::Float64, ::Float64)
   @ MistyClosures ~/.julia/packages/MistyClosures/4rFSA/src/MistyClosures.jl:22
 [2] (::Libtask.DynamicCallable{Dict{Any, Any}})(::Function, ::Float64, ::Float64)
   @ Libtask ~/projects/Libtask.jl/src/copyable_task.jl:1144
 [3] g
   @ ./REPL[47]:2 [inlined]
 [4] (::Tuple{…})(none::typeof(g))
   @ Base.Experimental ./<missing>:0
 [5] consume(t::TapedTask{Nothing, Tuple{typeof(g)}, MistyClosures.MistyClosure{Core.OpaqueClosure{Tuple{typeof(g)}, Any}}})
   @ Libtask ~/projects/Libtask.jl/src/copyable_task.jl:338
 [6] top-level scope
   @ REPL[48]:1
Some type information was truncated. Use `show(err)` to see complete types.

I'm not sure how MistyClosure/OpaqueClosure is supposed to handle VarArgs, but I think what happens here is that we end up in a situation where we have a DynamicCallable being called with sig = Tuple{typeof(Base.vect), Float64, Float64}. There’s nothing for this signature in the cache, so it calls build_callable, which then calls Base.code_ircode_by_type(sig)[1][1], which returns ir with ir.argtypes = Any[Core.Const(Base.vect), Tuple{Float64, Float64}] I think that then results in a MistyClosure that expects Tuple{Float64, Float64}, but we call it with two Float64s, and things go wrong.

May or may not relate to #185

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions