Skip to content

Invoking Core._apply #30105

@dalum

Description

@dalum

This one has left me head scratching:

julia> hasmethod(Core._apply, Tuple{typeof(+), Tuple{Float64, Float64}})
true

julia> applicable(Core._apply, +, (2.0, 2.0))
true

julia> applicable(invoke, Core._apply, Tuple{typeof(+), Tuple{Float64, Float64}}, +, (2.0, 2.0))
true

julia> invoke(Core._apply, Tuple{typeof(+), Tuple{Float64, Float64}}, +, (2.0, 2.0))
ERROR: MethodError: no method matching _apply(::typeof(+), ::Tuple{Float64,Float64})
Stacktrace:
 [1] top-level scope at none:0

The issue is that invoke(Core._apply, ...) doesn't work for any arguments. The easiest fix would be to make applicable not lie about being able to call invoke with the given arguments, but I think it would be even better if invoke(Core._apply, ...) worked. 🙂

I discovered this when using Cassette to replace internal calls by invoke, but the fact that Core._apply can't be used with invoke breaks my assumption that f(x, y) == invoke(f, Tuple{typeof(x), typeof(y)}, x, y).

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