IRTools.jl icon indicating copy to clipboard operation
IRTools.jl copied to clipboard

Dispatch doesn't work

Open MikeInnes opened this issue 5 years ago • 1 comments

We can't define a dynamo just for a subset of methods.

julia> @dynamo function foo(f, x::Real)
         IR(f, x)
       end

julia> foo(sin, 0.5)
ERROR: Error compiling @dynamo typeof(foo) on (typeof(sin), Float64):
MethodError: no method matching transform(::Type{typeof(foo)}, ::Type{typeof(sin)}, ::Type{Float64})

This is doubly-wrong because (a) the generated function entry point has no type restrictions at all and (b) the transform inner function does have them, but they need to be lifted to accept an equivalent set of types rather than values (exactly like a generated function).

MikeInnes avatar Jan 22 '20 13:01 MikeInnes

#42 address the second part of this. The first part is a bit tricky because we currently want the generated function to have a single args... slot so that the slots in the IR can easily be mapped to that original slot. I'm not sure we can express the right type signature directly there, so we might just have to settle for a more complicated mapping.

MikeInnes avatar Jan 22 '20 13:01 MikeInnes