Skip to content

Found bug in type-inference with apply(f, args...; kwargs...) = f(args...; kwargs...) #36626

@schlichtanders

Description

@schlichtanders

Unfortunately this is currently blocking me ;-) but at least I could simplify it so that other can find a workaround or actually fix it.

in current julia 1.4 I get the following

julia> apply(f, args...; kwargs...) = f(args...; kwargs...)
apply (generic function with 1 method)

julia> Base.promote_op(apply, typeof(apply), typeof(sin), Int)
Any

julia> apply2(f, args...; kwargs...) = f(args...; kwargs...)
apply2 (generic function with 1 method)

julia> Base.promote_op(apply, typeof(apply2), typeof(sin), Int)
Float64

julia> Base.promote_op(apply2, typeof(apply2), typeof(sin), Int)
Float64

julia> Base.promote_op(apply, typeof(apply), typeof(sin), Int)
Any

here again for quick copy and paste to try it yourself

apply(f, args...; kwargs...) = f(args...; kwargs...)
Base.promote_op(apply, typeof(apply), typeof(sin), Int)
apply2(f, args...; kwargs...) = f(args...; kwargs...)
Base.promote_op(apply, typeof(apply2), typeof(sin), Int)
Base.promote_op(apply2, typeof(apply2), typeof(sin), Int)
Base.promote_op(apply, typeof(apply), typeof(sin), Int)

and here with switched names

apply2(f, args...; kwargs...) = f(args...; kwargs...)
Base.promote_op(apply2, typeof(apply2), typeof(sin), Int)
apply(f, args...; kwargs...) = f(args...; kwargs...)
Base.promote_op(apply2, typeof(apply), typeof(sin), Int)
Base.promote_op(apply, typeof(apply), typeof(sin), Int)
Base.promote_op(apply2, typeof(apply2), typeof(sin), Int)

As you yourself can check, the unexpected outputs do not depend on the specific names, but seems to have todo with being the "first" or the "second" apply. Quite unbelievable.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions